def annotate_highlight(orig, web, req, tmpl): mt = ''.join(tmpl('mimetype', encoding=encoding.encoding)) if 'html' in mt: fctx = webutil.filectx(web.repo, req) style = web.config('web', 'pygments_style', 'colorful') highlight.pygmentize('annotateline', fctx, style, tmpl) return orig(web, req, tmpl)
def pygmentize(web, field, fctx, tmpl): style = web.config('web', 'pygments_style', 'colorful') expr = web.config('web', 'highlightfiles', "size('<5M')") filenameonly = web.configbool('web', 'highlightonlymatchfilename', False) ctx = fctx.changectx() tree = fileset.parse(expr) mctx = fileset.matchctx(ctx, subset=[fctx.path()], status=None) if fctx.path() in fileset.getset(mctx, tree): highlight.pygmentize(field, fctx, style, tmpl, guessfilenameonly=filenameonly)
def filerevision_highlight(orig, web, tmpl, fctx): mt = ''.join(tmpl('mimetype', encoding=encoding.encoding)) # only pygmentize for mimetype containing 'html' so we both match # 'text/html' and possibly 'application/xhtml+xml' in the future # so that we don't have to touch the extension when the mimetype # for a template changes; also hgweb optimizes the case that a # raw file is sent using rawfile() and doesn't call us, so we # can't clash with the file's content-type here in case we # pygmentize a html file if 'html' in mt: style = web.config('web', 'pygments_style', 'colorful') highlight.pygmentize('fileline', fctx, style, tmpl) return orig(web, tmpl, fctx)