用于显示语法突出显示的HTML5标记 [英] HTML5 tag to display syntax highlighting
问题描述
我想知道是否有一个标签在HTML5中自动突出显示HTML和/或PHP的语法。
我正在写一本包含一些代码的指南。由于我使用了很多新的html5标签(我使用部分作为我的指南大纲),我想使用本机html5中的内容。
I was wondering if there was a tag that auto-highlights the syntax of HTML and or PHP in HTML5. I'm writing a guide that has some code in it. Since I'm using a lot of the new html5 tags (I use section for the outline of my guide) I would like to use something in native html5.
如果这样不存在,最好的方法是什么? (比如,PHP和CSS?)
If this does not exist, what is the best way to do this? (Like, PHP and CSS?)
推荐答案
我担心HTML5中没有类似的东西,但是你可以随时使用 highlight_string()
来自PHP。如果你想要一些纯粹在客户端上的东西,可以尝试使用类似美化的JS荧光笔,这就是StackOverflow用于代码突出显示的内容:
There's nothing like that in HTML5 I am afraid, but you can always use highlight_string()
from PHP. If you want something purely on the client side, try a JS highlighter like prettify, which is what StackOverflow uses for their code highlighting:
http://code.google.com/p/google-code-prettify/
以下是其他一些:
- SyntaxHighlighter
- SHJS (uses GNU Source-highlight definitions)
这篇关于用于显示语法突出显示的HTML5标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!