[PATCH] highlight: Only pygmentize for HTML mimetypes
Rocco Rutte
pdmef at gmx.net
Wed Sep 3 11:09:24 CDT 2008
# HG changeset patch
# User Rocco Rutte <pdmef at gmx.net>
# Date 1220457073 -7200
# Node ID e83536538c886a116e66ec39db743e16fb482e9c
# Parent a3fd4aa154afff901779639df0963e4e2848b7dd
highlight: Only pygmentize for HTML mimetypes
For non-html mimetypes it doesn't make much sense. This also fixes the
issue that highlight unconditionally adds a <link/> tag for its CSS to
the template's header (which is pointless in text/plain output).
diff --git a/hgext/highlight/__init__.py b/hgext/highlight/__init__.py
--- a/hgext/highlight/__init__.py
+++ b/hgext/highlight/__init__.py
@@ -25,14 +25,18 @@ web_annotate = webcommands.annotate
web_annotate = webcommands.annotate
def filerevision_highlight(web, tmpl, fctx):
- style = web.config('web', 'pygments_style', 'colorful')
- highlight.pygmentize('fileline', fctx, style, tmpl)
+ mt = ''.join(tmpl('mimetype', encoding=web.encoding))
+ if 'html' in mt:
+ style = web.config('web', 'pygments_style', 'colorful')
+ highlight.pygmentize('fileline', fctx, style, tmpl)
return web_filerevision(web, tmpl, fctx)
def annotate_highlight(web, req, tmpl):
- fctx = webutil.filectx(web.repo, req)
- style = web.config('web', 'pygments_style', 'colorful')
- highlight.pygmentize('annotateline', fctx, style, tmpl)
+ mt = ''.join(tmpl('mimetype', encoding=web.encoding))
+ if 'html' in mt:
+ fctx = webutil.filectx(web.repo, req)
+ style = web.config('web', 'pygments_style', 'colorful')
+ highlight.pygmentize('annotateline', fctx, style, tmpl)
return web_annotate(web, req, tmpl)
def generate_css(web, req, tmpl):
More information about the Mercurial-devel
mailing list