[英]How can I show syntax-highlighted Python code in a HTML-page?
Is it somehow possible to show syntax-highlighted python code in a webpage?是否有可能在网页中显示语法突出显示的 python 代码?
I found this:我找到了这个:
<pre class="brush: python">
# python code here
</pre>
However, it shows all the code in black.但是,它以黑色显示所有代码。 I want
import
to be orange, strings to be green.我希望
import
为橙色,字符串为绿色。
Is it possible to do this?是否有可能做到这一点?
Thank you!谢谢!
If you wish to only display code, python in this case, consider using Github gist .如果您只想显示代码 python 在这种情况下,请考虑使用 Github gist 。
You can then embed it using the 'embed' option on the top right corner.然后,您可以使用右上角的“嵌入”选项嵌入它。 It will give you a script tag that you can copy and add to your webpage like so:
它将为您提供一个脚本标签,您可以将其复制并添加到您的网页中,如下所示:
<script src="https://gist.github.com/username/a39a422ebdff6e732753b90573100b16.js"></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.