Skip to content

Better Syntax Highlighting with gatsby-remark-vscode

Posted on:March 22, 2020

Thanks to a tip-off by a friend, I recently switched over from Prism to a plugin called gatsby-remark-vscode, which uses VS Code’s highlighting engine to perform syntax highlighting on during build-time. Aside from the performance benefit from not having to execute PrismJS, VS Code’s engine is a lot more powerful and sophisticated. You can read more about its benefits in the README.

gatsby-remark-vscode also supports adding plugins from the VSCode ecosystem, which means having access to the full unlimited range of VS Code themes and syntax highlighting plugins for uncommon languages.

This came in useful when I had to support syntax highlighting for Haskell and Erlang.

I managed to find the correspoding VS Code plugins, kindly authored by JustusAdam for Haskell and pgourlain for Erlang.

However, they both had custom postinstall steps which did not allow them to be installed properly. There’s a npm install --ignore-scripts that you can use, but it will affect all packages as well, which I didn’t want.

I ended up forking the repos and removing the postinstall steps. I don’t expect to have to keep up to date with upstream much since this is just syntax highlighting, so this way suits me just fine.


npm install siawyoung/language-haskell siawyoung/vscode_erlang

then add the extensions to your gatsby-remark-vscode configuration:

extensions: ["language-haskell", "erlang"],