Can I use GitHub's Linguist as a replacement to Rouge in Jekyll

319 Views Asked by At

I want to improve syntax highlighting on my blog written in Jekyll. I've noticed that some languages (e.g. Scala) are not always correctly highlighted by Rouge (it performs wrong tokenization). In the same time GitHub's code examples and Gists are displaying Scala syntax correctly and apparently they use their own library, Linguist, to achieve better results.

Since patching Rouge looks like a long shot, is there a way to use Linguist to tokenize and create CSS for highlighting server-side?

1

There are 1 best solutions below

0
pchaigno On BEST ANSWER

is there a way to use Linguist to tokenize and create CSS for highlighting server-side?

No. Linguist only detects the language of files; it doesn't perform the highlighting itself.

On GitHub, the rules of syntax highlighting are defined by a set of grammars from Sublime Text, Atom, and TextMate packages. In the case of Scala, GitHub relies on scala/vscode-scala-syntax. Syntax highlighting itself is performed by a closed-source library owned by GitHub.

Since patching Rouge looks like a long shot

That might still be your best option, especially since, at the moment, the Rouge lexer for Scala doesn't seem too complex.