With bugs!

Bringing Visual Studio Code Syntax Highlighting to Jekyll

Bringing Visual Studio Code Syntax Highlighting to Jekyll

Day 1

Motivation

Since this is a programming blog, there is a 100% certainty that at some point I will need code snippets in some blog posts. I’ve never really liked online syntax highlighters, as I find most of them too bland. I do like the syntax highlighting I get with Visual Studio Code, though. (Especially the Dark+ theme.) I tried to port the style of that theme to Rouge (Jekyll uses kramdown, kramdown uses Rogue), but the supported syntax elements and regular expression based parsing didn’t make for enough specificity in the generated HTML for the stylesheet to match on. Since Visual Studio Code is open source, I wondered if it wouldn’t be possible (perhaps even simple) to port the syntax highlighting from Visual Studio Code to Jekyll.

Investigation

Language Server Protocol

I first thought that Language Server Protocol that Visual Studio Code created would be related to syntax highlighting. I looked through the code of both Visual Studio Code and the Rust Language Server to figure out how the Language Server Protocol was involved with syntax highlighting.

Eventually I stumbled across this post: https://stackoverflow.com/questions/38148857/customizing-syntax-highlighting-in-visual-studio-code and learned that the language servers are not part of the syntax highlighting. I’d seen the grammar files while looking for the syntax highlighting, and knew they were the TextMate grammar files. After a search for a Ruby implementation of TextMate grammar processing turned up nothing, I decided to make my own.

Journaled Investigation

Resources

Tags