JavaScript syntax highlighters

I'm really into writing documentation, and very often, this documentation must include code samples.

I wanted a JavaScript syntax highlighter that:
  1. involved very little hassle in setting up,
  2. worked like a real parser using parse trees to ensure accurate highlighting,
  3. and provided decent coverage of the most common programming languages in use today.
Obviously, by opting to go with a JavaScript syntax highlighter, I chose to forgo the option of doing my syntax highlighting on the server side. Doing it on the server side still interests me, but for immediate and practical reasons, the quickest way to get syntax highlighting in my documentation would be to do it on the client side.

I went searching around for JavaScript syntax highlighters, and these are the top three that met my criteria.
  1. Javascript code prettifier. This was the first decent one that I found. It's pretty basic but I got up and running very quickly. The documentation is sparse and the tone of the README quite terse, but it meant there was less for me to sift through. The neat thing about it is that it has automatic language detection.
  2. SHJS. This is more full featured than the Google tool, and supports a wider range of languages. It appears to be more mature than the other two. Unlike the Google solution, it doesn't offer automatic detection of programming languages.
  3. JUSH. I'd like to check it out in more detail later on, but the website says it only supports HTML, CSS, JavaScript, PHP and SQL. I needed highlighting of Java and Ruby, not to mention C and C++.
For now, I'm going with the Google code prettifier, just because it was the first one I found, integrated, and liked. One that I did not like was dp.syntaxHighlighter, mostly because it required that my code be in a TEXTAREA instead of a PRE (pre-formatted field).

Comments

Popular posts from this blog

Arrays in Visual Basic and classic ASP

JavaScript: Checking for undeclared and undefined variables

A fix for LaTeX "Missing $ inserted." console message