Probably a little too off-topic, but after years of using similar "custom" methods of doing syntax highlighting, trying several WordPress plugins to automatically highlight, and several other options, I have found embedding GitHub Gists in blog posts to be the most reliable and lowest maintenance approach.
This probably won't matter to most people, but if you're the kind of person that has tutorials or examples or any other kind of thing you try to keep up to date in a blog post over the years, things like TOhtml make it hard to quickly edit and maintain the code, while WordPress plugins invariably do a poor job, add too much to the processing time (though you should be using a caching solution), and break on upgrade. For me, GitHub's Gists were a godsend.
I had the same complaint and wrote a script to create static HTML from GitHub's Gists. I added the gist CSS rules to the rules for the WordPress theme I'm using, and now I can copy/paste the generated HTML into blog posts without fetching from GitHub.
It requires Python3 and PyQt (to execute Javascript), so it's pretty heavy weight, but I have them installed anyway, so it's worked well for me.
Unfortunately Gists aren't very viewable on a mobile (certainly on an iPhone) as they're truncated and there's no way to scroll to the right. A number of times I've been disappointed to find articles (The Zen of R that's on the front page at the moment, for example) that I can't read. There's a button to view in raw but it's a bit of a shame that I can't view the content with highlighting and proper (non)wrapping.
.. code: python
>>> from bulbs.neo4jserver import Graph
>>> g = Graph()
ReStructuredText also allows you to easily add CSS classes to the markup without dropping down into the raw HTML. The rst container directive (http://docutils.sourceforge.net/docs/ref/rst/directives.html...) enables you to add divs so you can allow the content to drive the page layout instead of always being boxed in by the same default template.
EDIT: Also, note that while the VIM one uses a bunch of <font color="..."> tags, the Emacs one uses a bunch of span tags with reasonable class names like "function-name" or "string", so it produces much nicer code and is easy to use with your own CSS.
Hmm, on mine (GNU Emacs 23.3.1 on Fedora) it's M-x htmlfontify-buffer. It came with the Emacs distribution as standard. I suspect htmlize-buffer is either from some external package or from a different version of Emacs.
Doesn't basically every text editor support something like this? E.g. Notepad++ has NppExport->Export to HTML (Example output: https://gist.github.com/2056841)
FWIW I'v been using Text::VimColor (Perl interface to vim's syntax hilighting) on my blog for several years now. Mostly because I talk a lot about Perl 6, and there aren't many hilighters for Perl 6 code around.
In the beginning it sometimes produced Mojibake, which I finally nailed on a missing locale. And it's a bit slower than the usual hilighter, because it spawns a new vim process for each snippet to be hilighted. Still a good choice.
Related question: are all syntax highlighters awful to read for people who depend on accessibility tools, or is there actually a way to present code in a way that is accessible to these people?
Currenly, I just decorate the <pre> and <code> tags with CSS (as much as I would love line numbers).
I don't know if I understood you correctly, but you could add line numbers with before pseudo elements and use JavaScript to add numbers to its content. No need to mess with the markup, just CSS and JavaScript.
Unfortunately, with the advent of TextMate/Sublime Text 2, I'm always disappointed when returning to VIM's syntax highlighting. It leaves a lot to be desired.
I'd love a JavaScript plugin to parse TextMate theme files and highlight blocks of code.
I don't see why... I've been able to do almost any color scheme from textmate or other editors. I have my favorite color scheme from textmate in VIM (Sunburst). Just make sure you're either using gvim or your terminal has 256 colors turned on.
The 256 color thing is the most important and was something I struggled with for a few years before I figured out the problem - on Linux it was always fine, but on OSX, wow it was bad. Couldn't figure out why till someone else said the fact same thing - 256 color mode.
The syntax schemes just either never have the number of unique keyword(-types) available or I assume since it's the case for every language I use... it's not possible with vim. If it is, then I lament the inferior set of default syntax highliting.
And yeah, I use gvim for the greater color palette. I'd take a screenshot, but my current tether is on 3G and my server is taking too long to launch Gvim over X
This is not sophisticated, nor webscale, nor using the fad of the week. But, it is non-the-less awesome because it does exactly what OA needs, right now, using a context appropriate amount of effort (i.e. near to none).
This probably won't matter to most people, but if you're the kind of person that has tutorials or examples or any other kind of thing you try to keep up to date in a blog post over the years, things like TOhtml make it hard to quickly edit and maintain the code, while WordPress plugins invariably do a poor job, add too much to the processing time (though you should be using a caching solution), and break on upgrade. For me, GitHub's Gists were a godsend.