Edgewall Software

Opened 13 years ago

Last modified 12 years ago

#10437 closed enhancement

Adding Pygments syntax highlighting for new file type does not work as documented — at Initial Version

Reported by: kriegaex@… Owned by:
Priority: normal Milestone: 1.0
Component: rendering Version: 0.12-stable
Severity: normal Keywords: pygments, mimetype, MIME type, syntax highlighting, syntax coloring
Cc: Emmanuel Blot Branch:
Release Notes:
API Changes:
Internal Changes:

Description

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 mime_map and 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 text/x-something to /etc/mime.types.
  • I explicitly set the MIME type via svn propset svn:mime-type text/x-something my_file for 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 (0)

Note: See TracTickets for help on using tickets.