Tag: code formatting

Code snippets and syntax highlighting

I’ve been looking for a decent WordPress plugin to handle syntax highlighting for my code so that it will format neatly. I’ve tried a bunch of them so far, and am still not completely satisfied.

Requirements

  1. Has to correctly highlight GML syntax.
  2. Should support automatic line numbering
  3. Should work in both <pre> (for correctly-indented code blocks) and <code> (for inline textual elements in the middle of a paragraph that should be formatted as code.
  4. Nice if it treats <code> as an inline tag (this is definable via CSS, but it seems that WordPress’s TinyMCE visual editor will convert the entire paragraph into a <code> element, rather than just the content that is actually selected, making it annoying when you want to include some inline text in the middle of a paragraph and have it formatted as <code>.
  5. The font used for inline <code> tags should be typographically not-ugly when nested inside normal text.

After trying out a number of plugins, I’m currently using WP-Syntax, which seems to be the best out of the plugins I’ve tried so far. Overall this is a very good code formatting/syntax highlighting plugin, but for some reason the every-other-line background coloring doesn’t line up cleanly with each line of code, and it works using <pre> tags only, not <code> tags. WP-Syntax works with a couple other plugins as well, which integrates with the TinyMCE visual editor, and enables me to make a formatted code object downloadable.

I’m still looking for ways to improve the presentation of code, so if you’re reading this and have suggestions, please drop me a comment.