Java 有哪些突出显示库的代码?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/221570/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What code highlighting libs are there for Java?
提问by Fabian Buch
I'd like them to be easy to bundle, with few dependencies and easy to use.
我希望它们易于捆绑、依赖项少且易于使用。
采纳答案by Miguel Ping
Do you want to highlight Java code or use a Java lib to highlight some other code?
您想突出显示 Java 代码还是使用 Java 库突出显示其他一些代码?
I use these two: https://jhighlight.dev.java.net/(server-side) for xml and http://code.google.com/p/syntaxhighlighter/(js lib) for other stuff. The latter has something called 'brushes' which are "pluggable" .js for several langauges. If you are doing simple highlighting, I recommend the ,js approach.
我使用这两个:https: //jhighlight.dev.java.net/(服务器端)用于 xml 和http://code.google.com/p/syntaxhighlighter/(jslib)用于其他东西。后者有一种叫做“画笔”的东西,它是“可插入”的 .js,适用于多种语言。如果您正在做简单的突出显示,我推荐 ,js 方法。
回答by Zorkus
http://tohtml.com/this one is good.
http://tohtml.com/这个不错。
回答by cchantep
A little update, as we were recently looking for highlighting lib, we found the very good Jygments : http://code.google.com/p/jygments/.
一个小小的更新,因为我们最近在寻找高亮的 lib,我们发现了非常好的 Jygments:http: //code.google.com/p/jygments/。
Available for Ant/Maven/SBT projects throught threecrickets repo, it's a Java port of Pygments ( http://pygments.org), working for several major languages.
通过threecrickets repo 可用于Ant/Maven/SBT 项目,它是Pygments ( http://pygments.org)的Java 端口,适用于多种主要语言。

