pygments support in hgweb

Adam Hupp adam at
Sun Nov 4 17:55:21 CST 2007

I've modified hgweb to apply pygments syntax highlighting in the file
revision view.  It's based on this patch[0] but has the following

 * uses an external css file instead of inline styles.
 * falls back to a plain view if pygments is not available or is disabled
 * language determined based on file extension and contents
 * supports striped line highlighting

The changes are available in this repo:

That repository is running the changes.

One issue I ran into was an "unloaded module not callable" error
within pygments.  This was resolved by adding
mercurial.demandimport.disable() at the top of  That's
probably not the right solution but I'm not sure how else to handle

Is there any interest in including this change in mercurial?


Adam Hupp |

More information about the Mercurial-devel mailing list