【问题标题】:Is there a way to convert a code-file to an image with syntaxhiglighting有没有办法使用语法将代码文件转换为图像
【发布时间】:2021-06-09 23:04:53
【问题描述】:

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

我对任何提示都很满意 :) 谢谢

【问题讨论】:

    标签: image syntax-highlighting pango


    【解决方案1】:

    我找到了一个旧的 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
    

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

    【讨论】:

      猜你喜欢
      • 2022-08-12
      • 1970-01-01
      • 1970-01-01
      • 2020-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-31
      相关资源
      最近更新 更多