Re: Pygments + Groovy

42 views
Skip to first unread message

RjOllos

unread,
Jun 13, 2012, 6:49:48 AM6/13/12
to trac-...@googlegroups.com
On Tuesday, June 12, 2012 12:01:34 PM UTC-7, Jason Winnebeck wrote:
I am trying to get my Trac to support syntax highlighting of Groovy code. I am using Trac 0.12 and Pygments 1.5 (just upgraded from 1.4). Groovy highlighting is a new feature to 1.5: http://pygments.org/docs/lexers/#pygments-lexers-for-jvm-languages.

After upgrading Pygments with easy_install, I can see Pygments 1.5 in "about Trac". But when I use wiki with #!groovy and also load .groovy files, there is no highlighting. In the wiki, if I use #!text/x-groovy, it works. I have tried restarting Apache to cause Trac to totally reload...

The languages Trac can use with Pygments, it's not hard-coded is it? Or is the binding for things like "#!java" hard-coded into Trac source code?

I ran across this issue again recently and made a note to myself to add some additional documentation to Trac under TracSyntaxColoring (1), but haven't gotten around to it yet.

One way to accomplish this is to add an entry to [mimeviewer] mime_map (2). Here is an entry I recently added to add a wiki processor for batch files:

[mimeviewer]
mime_map = application/x-dos-batch:batch

After you successfully add an entry, it will be listed by the KnownMimeTypes macro (3).

For a widely-used language like groovy, you could request that an entry be added to the KNOWN_MIME_TYPES, as I did in (4).

(1) http://trac.edgewall.org/wiki/TracSyntaxColoring
(2) http://trac.edgewall.org/wiki/TracIni#mimeviewer-section
(3) https://trac.physiosonics.com/wiki/TracSyntaxColoring#KnownMIMETypes
(4) http://trac.edgewall.org/ticket/9097

Jason Winnebeck

unread,
Jun 14, 2012, 11:21:04 AM6/14/12
to trac-...@googlegroups.com
Thanks, I got the impression that since so many lexers are added constantly to Pygments, and that  http://pygments.org/docs/lexers/  appeared to be auto-generated that there was probably some way for Trac to iterate over supported Pygments lexers. for example the lexers doc showed the "short names" and file extensions; I thought maybe Trac enumerated those. Maybe it is possible to do that and no one has done it yet? If so, I don't think I'm up to it.

I did decide to make a patch like you did on ticket 9097, because of how easy it was. I filed the ticket as  http://trac.edgewall.org/ticket/10725. Since I already had my code modified, I just rebuilt and installed Trac that way instead of modifying the ini file (I follow svn branches/0.12-stable and periodically python setup.py install on that SVN working copy).

BTW, thanks for your work on maintaining plantuml, while checking my plugin SVN checkouts I saw you committed a patch for that horribly annoying comma bug!!!

Jason
Reply all
Reply to author
Forward
0 new messages