highlight vs. pygments

684 views
Skip to first unread message

a¿ex

unread,
Jan 15, 2008, 1:35:44 AM1/15/08
to Trac Users
Hi all,

did anybody already replaced pygments syntax highlighting by highlight
(http://www.andre-simon.de/) ?

Highlight seems significantly faster, than pygments and I would like
to try the performance difference in my trac browser. Any pointers
where to start?

TIA

Emmanuel Blot

unread,
Jan 15, 2008, 4:03:38 AM1/15/08
to trac-...@googlegroups.com
> did anybody already replaced pygments syntax highlighting by highlight
> (http://www.andre-simon.de/) ?

Other engines such as enscript and silvercity have been 'deprecated'
in Trac in favor of Pygments.
The reason is that Pygments is written in Python so installing it
requires virtually zero effort, while engines written in C, C++ (such
as highlight) etc. bring their own load of issues:
compilation, dependencies issues, etc. Highlight may exhibit better
performances, but it would be a step back.
One of the main issue with Trac installation was about dependencies.
That's one of the reasons why Trac has moved from ClearSilver
templating engine to Genshi.

Note that you can always write a plugin for Trac to use highlight as
your syntax highlighting engine.

Cheers,
Manu

Alex da Franca

unread,
Jan 15, 2008, 6:19:52 AM1/15/08
to trac-...@googlegroups.com
Thanks for the info.

That's what I meant to ask. Sorry for not being clearer on that.
Sure I can understand very well, that Highlight isn't suited to be the
standard engine.
It's a custom install (very straightforward btw) and thus it should be
optional in any case, but I would like to be able to override the use
of pygments in favor of Highlight, at least to give it a try.

I was asking for a starting point or get a hint, whether someone
already did something like that.
I have a few very long scripts, which take rather long to render.

Emmanuel Blot

unread,
Jan 15, 2008, 6:25:39 AM1/15/08
to trac-...@googlegroups.com
> I was asking for a starting point or get a hint, whether someone
> already did something like that.
> I have a few very long scripts, which take rather long to render.

Ok. Have a look at trac/mimeview/enscript.py and trac/mimeview/silvercity.py
It should give you the entry points you're looking for to add
highlight support for Trac.

Cheers,
Manu

Alex da Franca

unread,
Jan 15, 2008, 10:31:08 AM1/15/08
to trac-...@googlegroups.com

thanks, that helps.
Doesn't look too complicated at the first glance.
Too bad I haven't enough time on hands to start right away. :-(
Anyway many thanks for taking the time to answer.

Armin Ronacher

unread,
Jan 16, 2008, 11:04:35 AM1/16/08
to Trac Users
Hi,

On Jan 15, 7:35 am, "a¿ex" <dafra...@gmail.com> wrote:
> Hi all,
>
> did anybody already replaced pygments syntax highlighting by highlight
> (http://www.andre-simon.de/) ?
>
> Highlight seems significantly faster, than pygments and I would like
> to try the performance difference in my trac browser.
Don't forget that pygments is written in Python and a lot more
accurate than highlight. Pygments is able to highlight complex
languages such as Ruby or Perl and it can handle nested lexers such as
JavaScript in HTML. If you encounter a situation where pygments
highlights too slow for you please tell send us the input file and
which lexer is used and we try to optimize that lexer. In the past we
for example had a bug in the Java lexer which resulted in exponential
runtime for some files.

But to get your sourcecode browser faster the best thing would be to
add a cache to trac that caches highlighted files for 10 minutes or
so.

Regards,
Armin
Reply all
Reply to author
Forward
0 new messages