56 mctx = fileset.matchctx(ctx, subset=[fctx.path()], status=None) |
56 mctx = fileset.matchctx(ctx, subset=[fctx.path()], status=None) |
57 if fctx.path() in fileset.getset(mctx, tree): |
57 if fctx.path() in fileset.getset(mctx, tree): |
58 highlight.pygmentize(field, fctx, style, tmpl, |
58 highlight.pygmentize(field, fctx, style, tmpl, |
59 guessfilenameonly=filenameonly) |
59 guessfilenameonly=filenameonly) |
60 |
60 |
61 def filerevision_highlight(orig, web, req, fctx): |
61 def filerevision_highlight(orig, web, fctx): |
62 mt = ''.join(web.tmpl('mimetype', encoding=encoding.encoding)) |
62 mt = ''.join(web.tmpl('mimetype', encoding=encoding.encoding)) |
63 # only pygmentize for mimetype containing 'html' so we both match |
63 # only pygmentize for mimetype containing 'html' so we both match |
64 # 'text/html' and possibly 'application/xhtml+xml' in the future |
64 # 'text/html' and possibly 'application/xhtml+xml' in the future |
65 # so that we don't have to touch the extension when the mimetype |
65 # so that we don't have to touch the extension when the mimetype |
66 # for a template changes; also hgweb optimizes the case that a |
66 # for a template changes; also hgweb optimizes the case that a |
68 # can't clash with the file's content-type here in case we |
68 # can't clash with the file's content-type here in case we |
69 # pygmentize a html file |
69 # pygmentize a html file |
70 if 'html' in mt: |
70 if 'html' in mt: |
71 pygmentize(web, 'fileline', fctx, web.tmpl) |
71 pygmentize(web, 'fileline', fctx, web.tmpl) |
72 |
72 |
73 return orig(web, req, fctx) |
73 return orig(web, fctx) |
74 |
74 |
75 def annotate_highlight(orig, web, req, tmpl): |
75 def annotate_highlight(orig, web): |
76 mt = ''.join(web.tmpl('mimetype', encoding=encoding.encoding)) |
76 mt = ''.join(web.tmpl('mimetype', encoding=encoding.encoding)) |
77 if 'html' in mt: |
77 if 'html' in mt: |
78 fctx = webutil.filectx(web.repo, web.req) |
78 fctx = webutil.filectx(web.repo, web.req) |
79 pygmentize(web, 'annotateline', fctx, web.tmpl) |
79 pygmentize(web, 'annotateline', fctx, web.tmpl) |
80 |
80 |
81 return orig(web, req, web.tmpl) |
81 return orig(web) |
82 |
82 |
83 def generate_css(web, req, tmpl): |
83 def generate_css(web): |
84 pg_style = web.config('web', 'pygments_style', 'colorful') |
84 pg_style = web.config('web', 'pygments_style', 'colorful') |
85 fmter = highlight.HtmlFormatter(style=pg_style) |
85 fmter = highlight.HtmlFormatter(style=pg_style) |
86 web.res.headers['Content-Type'] = 'text/css' |
86 web.res.headers['Content-Type'] = 'text/css' |
87 web.res.setbodybytes(''.join([ |
87 web.res.setbodybytes(''.join([ |
88 '/* pygments_style = %s */\n\n' % pg_style, |
88 '/* pygments_style = %s */\n\n' % pg_style, |