[PATCH 2 of 6 RFC] highlight: allow specifying pygments style without an underscore

Augie Fackler raf at durin42.com
Fri Aug 2 09:15:01 CDT 2013


# HG changeset patch
# User Augie Fackler <durin42 at gmail.com>
# Date 1374709201 14400
#      Wed Jul 24 19:40:01 2013 -0400
# Node ID be6b7556262b8ac6c9f8f7231677f2b9a1f7fcf1
# Parent  123bd5dda28b5452afd8881488d14056f53ae421
highlight: allow specifying pygments style without an underscore

diff --git a/hgext/highlight/__init__.py b/hgext/highlight/__init__.py
--- a/hgext/highlight/__init__.py
+++ b/hgext/highlight/__init__.py
@@ -26,6 +26,8 @@
 from mercurial import extensions, encoding
 testedwith = 'internal'
 
+_stylekey = ['pygmentsstyle', 'pygments_style']
+
 def filerevision_highlight(orig, web, tmpl, fctx):
     mt = ''.join(tmpl('mimetype', encoding=encoding.encoding))
     # only pygmentize for mimetype containing 'html' so we both match
@@ -36,7 +38,7 @@
     # can't clash with the file's content-type here in case we
     # pygmentize a html file
     if 'html' in mt:
-        style = web.config('web', 'pygments_style', 'colorful')
+        style = web.config('web', _stylekey, 'colorful')
         highlight.pygmentize('fileline', fctx, style, tmpl)
     return orig(web, tmpl, fctx)
 
@@ -44,12 +46,12 @@
     mt = ''.join(tmpl('mimetype', encoding=encoding.encoding))
     if 'html' in mt:
         fctx = webutil.filectx(web.repo, req)
-        style = web.config('web', 'pygments_style', 'colorful')
+        style = web.config('web', _stylekey, 'colorful')
         highlight.pygmentize('annotateline', fctx, style, tmpl)
     return orig(web, req, tmpl)
 
 def generate_css(web, req, tmpl):
-    pg_style = web.config('web', 'pygments_style', 'colorful')
+    pg_style = web.config('web', _stylekey, 'colorful')
     fmter = highlight.HtmlFormatter(style = pg_style)
     req.respond(common.HTTP_OK, 'text/css')
     return ['/* pygments_style = %s */\n\n' % pg_style,


More information about the Mercurial-devel mailing list