JavaScript code prettifiers

If you need a JavaScript code prettifier you’ve got basically two options, google-code-prettify and SyntaxHighlighter. I just tried them both and here’s what I found.

google-code-prettify SyntaxHighlighter
Support Google Code site. No wiki. Project maintainer Alex Gorbatchev who seems quite helpful.
Languages highlighted Lots. Lots.
Hosting Must download yourself. Can load URLs directly. (Donate if you use this.)
Branding None. Shows a help “?” which activates a dialog asking for a donation.

How do they look? I needed YAML highlighting so that’s what my screenshots are of. (Incidentally, the YAML “brush” is not distributed with SyntaxHighlighter.)

Here’s the Google one. It parses strings wrong so only some words are highlighted. It gets dates. It gets comments. It gets numbers but interprets them as numbers even when they’re part of a string.

So I tried Alex’s with the YAML brush. It’s a little better. It colors the keys of the hash but it misses the first of each hash, maybe because it’s in a list. It doesn’t detect strings or dates. It has the same problem with numbers.

But the killer is that it resized my <pre> out of the boundary. I tried hard-coding width but that had no effect. So I’ll go with the Google one. Maybe someone will improve it, or if I really need to I will.

This entry was posted in Coding and tagged . Bookmark the permalink. Both comments and trackbacks are currently closed.
  • Subscribe

    Subscribe to all posts by feed.
  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1 other subscriber