# HG changeset patch # User Dirkjan Ochtman # Date 1206721910 -3600 # Node ID 55bc0a035e1f66e18f4d7c03f4fbb99b9878c9dd # Parent 894875eae49bbefd4fa5e4bf41b485f47b19fa60 highlight: some small cleanups diff -r 894875eae49b -r 55bc0a035e1f 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 - -- Adam Hupp - - """ 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') -def pygmentize(self, tmpl, fctx, field): +def pygmentize(field, fctx, style, tmpl): + # append a 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