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

login
register
mail settings
Submitter Augie Fackler
Date Aug. 2, 2013, 2:15 p.m.
Message ID <be6b7556262b8ac6c9f8.1375452901@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/1983/
State Deferred
Headers show

Comments

Augie Fackler - Aug. 2, 2013, 2:15 p.m.
# HG changeset patch
# User Augie Fackler <durin42@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

Patch

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,