有没有办法使用语法高亮将代码文件转换为图像

Is there a way to convert a code-file to an image with syntaxhiglighting

我尝试将 Pascal 代码文件转换为图像(jpg、png)并找到 pongo-view 作为一个很好的解决方案。有没有办法在输出文件中添加语法高亮显示?

我很高兴得到任何提示 :) 谢谢

我发现了一个旧的 repo 来添加带有 pango 标记的语法高亮 (https://github.com/LinuxJedi/pango-syntax-highlighter/)。所以新人现在可以将Pascal文件转换为带有语法高亮的图像。

https://github.com/thiemol/pango-syntax-highlighter

python3 pangosyntaxhighlight.py cpp myfile.cpp output.txt && pango-view --markup --font=mono -qo image.png output.txt

工作 with:C、C++、Java、Go'、Python、Scala、GLShaderLexer、xml。 现在还有 Delphi/Pacal、PhP。您可以简单地添加正确的词法分析器。