imagesyntax-highlightingpango

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


I try to convert Pascal-Code Files to an image (jpg, png) an find pongo-view as a good solution. Is there a way to add syntax-highlighting in the Output files?

I am happy about any hints :) Thanks


Solution

  • I found an old repo to add syntax highligthing with pango markup (https://github.com/LinuxJedi/pango-syntax-highlighter/). So the new one can now convert Pascal files to images with syntax highligthing.

    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
    

    Works with:C,C++,Java, Go', Python,Scala, GLShaderLexer, xml. Now also with Delphi/Pacal, PhP. You can simple add the right lexer.

    enter image description here