11

I'd like them to be easy to bundle, with few dependencies and easy to use.

Michael Berry
  • 70,193
  • 21
  • 157
  • 216
Fabian Buch
  • 831
  • 2
  • 9
  • 18

5 Answers5

8

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.

Miguel Ping
  • 18,082
  • 23
  • 88
  • 136
  • Apparently the syntaxhighligher js library is now located at http://alexgorbatchev.com/SyntaxHighlighter/ – Jason Webb Dec 09 '10 at 22:39
  • If you want server side simple highlighting, there are Java ports of syntaxhighlighter and of prettify. Have a look at my approach https://groups.google.com/forum/#!topic/java-prettify/AANTzgRe81k – Jmini Nov 12 '13 at 18:38
  • The first link is broken. – cristid9 May 20 '17 at 12:48
  • 1
    There is https://github.com/codelibs/jhighlight. Don't know for sure that it's the same project as https://jhighlight.dev.java.net/. – Robert Fleming Mar 05 '18 at 21:41
2

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.

cchantep
  • 9,118
  • 3
  • 30
  • 41
2

http://tohtml.com/ this one is good.

Zorkus
  • 484
  • 1
  • 4
  • 13
1

RSyntaxTextArea is worked for meHere

        RSyntaxTextArea textArea = new RSyntaxTextArea();
        textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
        textArea.setCodeFoldingEnabled(true);
        RTextScrollPane rs = new RTextScrollPane(textArea);