Live data from Hacker News

Add Syntax Highlighting To Your Blog With VIM

alexanderle.com

31–40 of 41 posts

Re: Add Syntax Highlighting To Your Blog With VIM

#31
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

 and  tags with CSS (as much as I would love line numbers).

Re: Add Syntax Highlighting To Your Blog With VIM

#32
post #31

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 and tags with CSS (as much as I would love line numbers).

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.

Re: Add Syntax Highlighting To Your Blog With VIM

#34

Pygments ( http://pygments.org/ ) will also turn code into syntax highlighted HTML.

Thanks. Pygments looks better than other solutions I've looked at. I just found a Ruby wrapper for Pygments: https://github.com/tmm1/pygments.rb

Re: Add Syntax Highlighting To Your Blog With VIM

#35

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.

Re: Add Syntax Highlighting To Your Blog With VIM

#36
post #6

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 an…

The key is to store the original, and to display the tohtml output. I'm kinda skeptical about embedding stuff from external sites; the more external dependencies you have, the less reliable your own blog becomes.

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.

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

Re: Add Syntax Highlighting To Your Blog With VIM

#39

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 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

Re: Add Syntax Highlighting To Your Blog With VIM

#40
post #38

Insert plug for pandoc. Among the many benefits pandoc provides is easy code highlighting. By defualt it uses pygments as others have suggested. http://johnmacfarlane.net/pandoc/README.html#verbatim-code-b...

pandoc uses kate-highlighting to highlight code snippets and not pygments
Post reply on HN