isidroas / code_to_pdf

This tool converts a folder of files in a printable A4 PDF
MIT License
3 stars 2 forks source link

Can we add syntax highlighting for .txs, .jsx? #14

Open avdeev opened 10 months ago

isidroas commented 10 months ago

The work of highlighting the source code based on the file extension is delegated to the pygments library. It seems that they don't support those extensions:

>>> from pygments.lexers import get_lexer_by_name
>>> get_lexer_by_name('py')
<pygments.lexers.PythonLexer>
>>> get_lexer_by_name('js')
<pygments.lexers.JavascriptLexer>
>>> get_lexer_by_name('jsx')
Traceback (most recent call last):
...
pygments.util.ClassNotFound: no lexer for alias 'jsx' found
>>> get_lexer_by_name('txs')
Traceback (most recent call last):
...
pygments.util.ClassNotFound: no lexer for alias 'txs' found

You could request that enhancement to them: https://github.com/pygments/pygments/issues