我可以用 GitHub 的 Linguist 代替 Jekyll 中的 Rouge 吗

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

我想改进我用 Jekyll 编写的博客上的语法突出显示。我注意到某些语言(例如 Scala)并不总是被 Rouge 正确突出显示(它执行错误的标记化)。同时 GitHub 的代码示例和 Gists 正确显示 Scala 语法,显然他们使用自己的库 Linguist 来获得更好的结果。

由于修补 Rouge 看起来很困难,有没有办法使用 Linguist 进行标记化并创建 CSS 以突出显示服务器端?

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

没有。 仅限语言学家检测文件的语言it doesn't perform the highlighting itself.

在GitHub上,语法高亮规则由a set of grammars from Sublime Text, Atom, and TextMate packages. In the case of Scala, GitHub relies on scala/vscode-scala-syntax定义。语法突出显示本身由 GitHub.

拥有的闭源库执行

Since patching Rouge looks like a long shot

这可能仍然是您的最佳选择,尤其是因为目前 the Rouge lexer for Scala 似乎并不太复杂。