Add Syntax Highlighting To Your Blog With VIM
alexanderle.com
alexanderle.com
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'm kinda skeptical about embedding stuff from external sites; the more external dependencies you have, the less reliable your own blog becomes.
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.
A brief explanation and the code is here: http://jlarocco.com/2011/12/22/static-gist-creator/
And just the code is here: https://gist.github.com/1513192
> (...) and there's no way to scroll to the right
Just swipe using two fingers, and everything works as intended.In Lightbulb, I used the rst Pygments CodeBlock directive by Georg Brandl (https://github.com/espeed/lightbulb/blob/master/lightbulb/di...) to incorporate code blocks like in Sphinx:
.. 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.See Jason Santa Maria's 12 min talk on this design concept http://vimeo.com/4394152.
Here's a sample of the output: http://inst.eecs.berkeley.edu/~tikhon/Interpreter.hs.html
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.
let html_use_css=1
let use_xhtml = 1
Although it creates some blank CSS.
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.
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.
http://johnmacfarlane.net/pandoc/README.html#verbatim-code-b...
produces file.html
Or, use perl's Text::VimColor http://search.cpan.org/~rwstauner/Text-VimColor-0.14/lib/Tex...
let html_use_css = 1
let use_xhtml = 1I'd love a JavaScript plugin to parse TextMate theme files and highlight blocks of code.
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