问题
I'd like them to be easy to bundle, with few dependencies and easy to use.
回答1:
Do you want to highlight Java code or use a Java lib to highlight some other code?
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.
回答2:
http://sourceforge.net/projects/jintilla/
http://syntax.jedit.org/
回答3:
http://tohtml.com/ this one is good.
回答4:
A little update, as we were recently looking for highlighting lib, we found the very good 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.
回答5:
RSyntaxTextArea is worked for meHere
RSyntaxTextArea textArea = new RSyntaxTextArea();
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
textArea.setCodeFoldingEnabled(true);
RTextScrollPane rs = new RTextScrollPane(textArea);
来源:https://stackoverflow.com/questions/221570/what-code-highlighting-libs-are-there-for-java