Adding Pygments syntax highlighting for new file type does not work as documented
|Reported by:||Owned by:|
|Severity:||normal||Keywords:||pygments, mimetype, MIME type, syntax highlighting, syntax coloring|
Mimetype associations can now be extended or overriden by regexps.
I failed for hours in adding syntax highlighting to Trac for a new file type I had added to my local Pygments installation before and which worked well with pygmentize on the console. The file type does not have shebang, but must be detected by a file name pattern (I need globbing, i.e. pattern matching for it because there is no fixed file extension).
The documentation talks about setting
pygments_modes in the
mimeviewer section of trac.ini, but this either did nothing or led to errors in Trac, stating that Pygmentize did not know the specified MIME type (I forgot the exact error message).
What I ended up doing were two things not mentioned in the documentation at all:
- I added a new (self-invented) MIME type
- I explicitly set the MIME type via
svn propset svn:mime-type text/x-something my_filefor each relevant file in my SVN repository.
Maybe there is another solution, but if so, the documentation does not mention it. What it does describe is incomplete at best and outright wrong in my opinion. So I request the following:
- Please correct and extend the documentation, adding a step-by-step tutorial for adding a new file type for syntax highlighting to Trac via Pygments.
- Please enable Trac to let Pygments determine the file type directly by its own file name patterns, because this works nicely in pygmentize. This would let most users get rid of having to modify mime.types and enable to correctly highlight files without a MIME type explicitly set in SVN. The advantages are clear: no MIME type fiddling, no trac.ini editing.
Change History (13)
comment:8 by , 8 years ago
|Milestone:||next-major-releases → 1.0|
|Type:||defect → enhancement|