stefan at sevenbyte.org
Mon Nov 4 21:46:40 CET 2013
I created a python script for the syntax-highlighting thing in cgit
which solves a few problems with the shipped script in cgit . I use
it in production since half a year.
- It uses python2 because there are still a lot of problems with
python3 and pygments out there. , 
- I used guess_lexer_for_filename for a better detecting of the used
languages (e.g. mixed HTML and PHP, HTML (Django)...).
guess_lexer_for_filename does not work with python3 yet.
- The script looks whether there is a shebang line if it cannot
determine the language.
- It maps cmakelists.txt and pkgbuild (arch linux package system) files
to the correct lexer. Any other filenames can be added easily.
- The CSS has to be defined in the CSS file to avoid inline CSS.
- `sys.stdin.read().decode(encoding='utf-8', errors='ignore')` is used
to ensure the functionality even for corrupted file encodings.
If you like my implementation I would be happy to create a patchfile. :)
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 490 bytes
Desc: This is a digitally signed message part
More information about the CGit