highlight: some small cleanups
authorDirkjan Ochtman <dirkjan@ochtman.nl>
Fri, 28 Mar 2008 17:31:50 +0100
changeset 6394 55bc0a035e1f
parent 6393 894875eae49b
child 6395 3f0294536b24
highlight: some small cleanups
hgext/highlight.py
--- a/hgext/highlight.py	Fri Mar 28 19:40:44 2008 +0100
+++ b/hgext/highlight.py	Fri Mar 28 17:31:50 2008 +0100
@@ -20,16 +20,11 @@
 
 # pygmentize -f html -S <newstyle>
 
-
 -- Adam Hupp <adam@hupp.org>
-
-
 """
 
 from mercurial import demandimport
-demandimport.ignore.extend(['pkgutil',
-                            'pkg_resources',
-                            '__main__',])
+demandimport.ignore.extend(['pkgutil', 'pkg_resources', '__main__',])
 
 from mercurial.hgweb import webcommands, webutil
 from mercurial import util
@@ -43,7 +38,8 @@
 SYNTAX_CSS = ('\n<link rel="stylesheet" href="#staticurl#highlight.css" '
               'type="text/css" />')
 
-def pygmentize(self, tmpl, fctx, field):
+def pygmentize(field, fctx, style, tmpl):
+
     # append a <link ...> to the syntax highlighting css
     old_header = ''.join(tmpl('header'))
     if SYNTAX_CSS not in old_header:
@@ -54,7 +50,6 @@
     if util.binary(text):
         return
 
-    style = self.config("web", "pygments_style", "colorful")
     # To get multi-line strings right, we can't format line-by-line
     try:
         lexer = guess_lexer_for_filename(fctx.path(), text,
@@ -83,12 +78,14 @@
 web_annotate = webcommands.annotate
 
 def filerevision_highlight(web, tmpl, fctx):
-    pygmentize(web, tmpl, fctx, 'fileline')
+    style = web.config('web', 'pygments_style', 'colorful')
+    pygmentize('fileline', fctx, style, tmpl)
     return web_filerevision(web, tmpl, fctx)
 
 def annotate_highlight(web, req, tmpl):
     fctx = webutil.filectx(web.repo, req)
-    pygmentize(web, tmpl, fctx, 'annotateline')
+    style = web.config('web', 'pygments_style', 'colorful')
+    pygmentize('annotateline', fctx, style, tmpl)
     return web_annotate(web, req, tmpl)
 
 # monkeypatch in the new version