Show More
@@ -20,16 +20,11 b' file should be re-generated by running' | |||||
20 |
|
20 | |||
21 | # pygmentize -f html -S <newstyle> |
|
21 | # pygmentize -f html -S <newstyle> | |
22 |
|
22 | |||
23 |
|
||||
24 | -- Adam Hupp <adam@hupp.org> |
|
23 | -- Adam Hupp <adam@hupp.org> | |
25 |
|
||||
26 |
|
||||
27 | """ |
|
24 | """ | |
28 |
|
25 | |||
29 | from mercurial import demandimport |
|
26 | from mercurial import demandimport | |
30 | demandimport.ignore.extend(['pkgutil', |
|
27 | demandimport.ignore.extend(['pkgutil', 'pkg_resources', '__main__',]) | |
31 | 'pkg_resources', |
|
|||
32 | '__main__',]) |
|
|||
33 |
|
28 | |||
34 | from mercurial.hgweb import webcommands, webutil |
|
29 | from mercurial.hgweb import webcommands, webutil | |
35 | from mercurial import util |
|
30 | from mercurial import util | |
@@ -43,7 +38,8 b' from pygments.formatters import HtmlForm' | |||||
43 | SYNTAX_CSS = ('\n<link rel="stylesheet" href="#staticurl#highlight.css" ' |
|
38 | SYNTAX_CSS = ('\n<link rel="stylesheet" href="#staticurl#highlight.css" ' | |
44 | 'type="text/css" />') |
|
39 | 'type="text/css" />') | |
45 |
|
40 | |||
46 |
def pygmentize( |
|
41 | def pygmentize(field, fctx, style, tmpl): | |
|
42 | ||||
47 | # append a <link ...> to the syntax highlighting css |
|
43 | # append a <link ...> to the syntax highlighting css | |
48 | old_header = ''.join(tmpl('header')) |
|
44 | old_header = ''.join(tmpl('header')) | |
49 | if SYNTAX_CSS not in old_header: |
|
45 | if SYNTAX_CSS not in old_header: | |
@@ -54,7 +50,6 b' def pygmentize(self, tmpl, fctx, field):' | |||||
54 | if util.binary(text): |
|
50 | if util.binary(text): | |
55 | return |
|
51 | return | |
56 |
|
52 | |||
57 | style = self.config("web", "pygments_style", "colorful") |
|
|||
58 | # To get multi-line strings right, we can't format line-by-line |
|
53 | # To get multi-line strings right, we can't format line-by-line | |
59 | try: |
|
54 | try: | |
60 | lexer = guess_lexer_for_filename(fctx.path(), text, |
|
55 | lexer = guess_lexer_for_filename(fctx.path(), text, | |
@@ -83,12 +78,14 b' web_filerevision = webcommands._filerevi' | |||||
83 | web_annotate = webcommands.annotate |
|
78 | web_annotate = webcommands.annotate | |
84 |
|
79 | |||
85 | def filerevision_highlight(web, tmpl, fctx): |
|
80 | def filerevision_highlight(web, tmpl, fctx): | |
86 | pygmentize(web, tmpl, fctx, 'fileline') |
|
81 | style = web.config('web', 'pygments_style', 'colorful') | |
|
82 | pygmentize('fileline', fctx, style, tmpl) | |||
87 | return web_filerevision(web, tmpl, fctx) |
|
83 | return web_filerevision(web, tmpl, fctx) | |
88 |
|
84 | |||
89 | def annotate_highlight(web, req, tmpl): |
|
85 | def annotate_highlight(web, req, tmpl): | |
90 | fctx = webutil.filectx(web.repo, req) |
|
86 | fctx = webutil.filectx(web.repo, req) | |
91 | pygmentize(web, tmpl, fctx, 'annotateline') |
|
87 | style = web.config('web', 'pygments_style', 'colorful') | |
|
88 | pygmentize('annotateline', fctx, style, tmpl) | |||
92 | return web_annotate(web, req, tmpl) |
|
89 | return web_annotate(web, req, tmpl) | |
93 |
|
90 | |||
94 | # monkeypatch in the new version |
|
91 | # monkeypatch in the new version |
General Comments 0
You need to be logged in to leave comments.
Login now