Mercurial > hg
comparison hgext/highlight/__init__.py @ 8874:74baf78202e8
highlight: was broken since 580a79dde2a3 (encoding)
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Sun, 21 Jun 2009 16:54:57 +0200 |
parents | 87c30fb7e8df |
children | 868670dbc237 |
comparison
equal
deleted
inserted
replaced
8873:e872ef2e6758 | 8874:74baf78202e8 |
---|---|
23 -- Adam Hupp <adam@hupp.org> | 23 -- Adam Hupp <adam@hupp.org> |
24 """ | 24 """ |
25 | 25 |
26 import highlight | 26 import highlight |
27 from mercurial.hgweb import webcommands, webutil, common | 27 from mercurial.hgweb import webcommands, webutil, common |
28 from mercurial import extensions | 28 from mercurial import extensions, encoding |
29 | 29 |
30 def filerevision_highlight(orig, web, tmpl, fctx): | 30 def filerevision_highlight(orig, web, tmpl, fctx): |
31 mt = ''.join(tmpl('mimetype', encoding=web.encoding)) | 31 mt = ''.join(tmpl('mimetype', encoding=encoding.encoding)) |
32 # only pygmentize for mimetype containing 'html' so we both match | 32 # only pygmentize for mimetype containing 'html' so we both match |
33 # 'text/html' and possibly 'application/xhtml+xml' in the future | 33 # 'text/html' and possibly 'application/xhtml+xml' in the future |
34 # so that we don't have to touch the extension when the mimetype | 34 # so that we don't have to touch the extension when the mimetype |
35 # for a template changes; also hgweb optimizes the case that a | 35 # for a template changes; also hgweb optimizes the case that a |
36 # raw file is sent using rawfile() and doesn't call us, so we | 36 # raw file is sent using rawfile() and doesn't call us, so we |
40 style = web.config('web', 'pygments_style', 'colorful') | 40 style = web.config('web', 'pygments_style', 'colorful') |
41 highlight.pygmentize('fileline', fctx, style, tmpl) | 41 highlight.pygmentize('fileline', fctx, style, tmpl) |
42 return orig(web, tmpl, fctx) | 42 return orig(web, tmpl, fctx) |
43 | 43 |
44 def annotate_highlight(orig, web, req, tmpl): | 44 def annotate_highlight(orig, web, req, tmpl): |
45 mt = ''.join(tmpl('mimetype', encoding=web.encoding)) | 45 mt = ''.join(tmpl('mimetype', encoding=encoding.encoding)) |
46 if 'html' in mt: | 46 if 'html' in mt: |
47 fctx = webutil.filectx(web.repo, req) | 47 fctx = webutil.filectx(web.repo, req) |
48 style = web.config('web', 'pygments_style', 'colorful') | 48 style = web.config('web', 'pygments_style', 'colorful') |
49 highlight.pygmentize('annotateline', fctx, style, tmpl) | 49 highlight.pygmentize('annotateline', fctx, style, tmpl) |
50 return orig(web, req, tmpl) | 50 return orig(web, req, tmpl) |