适用于 HTML5 的语法荧光笔?
有谁知道与 HTML5 docType 一起使用的语法荧光笔吗?我尝试过几个,包括 SyntaxHighlighter、Snippet 和其他一些,但它们似乎都不能正常工作。我通常不会在实现插件时遇到问题,所以我不认为这是我正在做的事情(尽管我从不排除这一点)。有人成功地将其中一个或另一个与 HTML5 结合使用吗?我知道这里有一些这样的帖子,但没有一个是最近的。
我希望重点介绍 PHP、HTML 和 JavaScript 语法。我更喜欢 jQuery 解决方案,但任何方法都可以。
Does anyone know of a syntax highlighter that works with the HTML5 docType? I have tried several including SyntaxHighlighter, Snippet and a few others but none of them seem to be working correctly. I never usually have issues implementing plugins so I don't think it is something I am doing (although I never rule that out). Is anyone using one or another of these with HTML5 successfully? I know there area few of these post on here but none that were really recent.
I am looking to highlight mostly PHP, HTML and JavaScript syntax. I would prefer a jQuery solution but anything will do.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您尝试过 Google 美化吗?我知道很多语言都支持,对于 HTML5 来说它可能已经足够更新了吗?
You tried Google Prettify? I know that does a lot of languages, it might be up to date enough for HTML5?
您是否尝试过 codemirror ?
它很容易使用,并且页面中的示例非常好。我认为类似于 this 或 this 这就是您所需要的
编辑
我过去使用过前两个,但我认为 SyntaxHighlighter 有更好的支持:
highlight.js
chill(使用 jQuery)
对 SyntaxHighlighter 的包装jQuery
Have you tried codemirror ?
It's easy to use, and the examples in the page are pretty good. I think something like this or this it's what you need
EDIT
I've used the first two in the past, but I think SyntaxHighlighter has better support:
highlight.js
chill (with jQuery)
Wrapper to SyntaxHighlighter in jQuery
您可能想查看JavaScript 语法荧光笔的完全不公平比较 作者:Ivan Sagalaev,Highlight.js。他自然偏爱自己的,但对此非常坦率,而且比较也很彻底。
对我个人来说,Highlight.js 缺少行编号是一个大问题,但除此之外它看起来很强大并且支持 HTML5
标签,而不是必须使用
You might want to check out Completely Unfair Comparison of JavaScript Syntax Highlighters by Ivan Sagalaev, the creator of Highlight.js. He favors his own, naturally, but is very upfront about it and the comparison is thorough.
Highlight.js' lack of line numbering is a deal-breaker for me personally, but otherwise it seems strong and does support HTML5
<code>
tags rather than having to use<pre>
by itself or<script>
tags.