Show More
@@ -296,6 +296,7 b' test-hgweb.t' | |||
|
296 | 296 | test-hgwebdir-paths.py |
|
297 | 297 | test-hgwebdir.t |
|
298 | 298 | test-hgwebdirsym.t |
|
299 | test-highlight.t | |
|
299 | 300 | test-histedit-arguments.t |
|
300 | 301 | test-histedit-base.t |
|
301 | 302 | test-histedit-bookmark-motion.t |
@@ -36,6 +36,7 b' from mercurial.hgweb import (' | |||
|
36 | 36 | |
|
37 | 37 | from mercurial import ( |
|
38 | 38 | extensions, |
|
39 | pycompat, | |
|
39 | 40 | ) |
|
40 | 41 | |
|
41 | 42 | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
@@ -79,11 +80,12 b' def annotate_highlight(orig, web):' | |||
|
79 | 80 | |
|
80 | 81 | def generate_css(web): |
|
81 | 82 | pg_style = web.config('web', 'pygments_style', 'colorful') |
|
82 | fmter = highlight.HtmlFormatter(style=pg_style) | |
|
83 | fmter = highlight.HtmlFormatter(style=pycompat.sysstr(pg_style)) | |
|
83 | 84 | web.res.headers['Content-Type'] = 'text/css' |
|
85 | style_defs = fmter.get_style_defs(pycompat.sysstr('')) | |
|
84 | 86 | web.res.setbodybytes(''.join([ |
|
85 | 87 | '/* pygments_style = %s */\n\n' % pg_style, |
|
86 |
|
|
|
88 | pycompat.bytestr(style_defs), | |
|
87 | 89 | ])) |
|
88 | 90 | return web.res.sendresponse() |
|
89 | 91 |
@@ -15,6 +15,7 b" demandimport.IGNORES.update(['pkgutil', " | |||
|
15 | 15 | |
|
16 | 16 | from mercurial import ( |
|
17 | 17 | encoding, |
|
18 | pycompat, | |
|
18 | 19 | ) |
|
19 | 20 | |
|
20 | 21 | from mercurial.utils import ( |
@@ -61,11 +62,12 b' def pygmentize(field, fctx, style, tmpl,' | |||
|
61 | 62 | |
|
62 | 63 | # Pygments is best used with Unicode strings: |
|
63 | 64 | # <http://pygments.org/docs/unicode/> |
|
64 | text = text.decode(encoding.encoding, 'replace') | |
|
65 | text = text.decode(pycompat.sysstr(encoding.encoding), 'replace') | |
|
65 | 66 | |
|
66 | 67 | # To get multi-line strings right, we can't format line-by-line |
|
67 | 68 | try: |
|
68 | lexer = guess_lexer_for_filename(fctx.path(), text[:1024], | |
|
69 | path = pycompat.sysstr(fctx.path()) | |
|
70 | lexer = guess_lexer_for_filename(path, text[:1024], | |
|
69 | 71 | stripnl=False) |
|
70 | 72 | except (ClassNotFound, ValueError): |
|
71 | 73 | # guess_lexer will return a lexer if *any* lexer matches. There is |
@@ -84,10 +86,10 b' def pygmentize(field, fctx, style, tmpl,' | |||
|
84 | 86 | if isinstance(lexer, TextLexer): |
|
85 | 87 | return |
|
86 | 88 | |
|
87 | formatter = HtmlFormatter(nowrap=True, style=style) | |
|
89 | formatter = HtmlFormatter(nowrap=True, style=pycompat.sysstr(style)) | |
|
88 | 90 | |
|
89 | 91 | colorized = highlight(text, lexer, formatter) |
|
90 | coloriter = (s.encode(encoding.encoding, 'replace') | |
|
92 | coloriter = (s.encode(pycompat.sysstr(encoding.encoding), 'replace') | |
|
91 | 93 | for s in colorized.splitlines()) |
|
92 | 94 | |
|
93 | 95 | tmpl._filters['colorize'] = lambda x: next(coloriter) |
General Comments 0
You need to be logged in to leave comments.
Login now