Mercurial > hg-stable
changeset 6394:55bc0a035e1f
highlight: some small cleanups
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Fri, 28 Mar 2008 17:31:50 +0100 |
parents | 894875eae49b |
children | 3f0294536b24 |
files | hgext/highlight.py |
diffstat | 1 files changed, 7 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- 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