6 # GNU General Public License version 2 or any later version. |
6 # GNU General Public License version 2 or any later version. |
7 # |
7 # |
8 # The original module was split in an interface and an implementation |
8 # The original module was split in an interface and an implementation |
9 # file to defer pygments loading and speedup extension setup. |
9 # file to defer pygments loading and speedup extension setup. |
10 |
10 |
|
11 from __future__ import absolute_import |
|
12 |
|
13 import pygments |
|
14 import pygments.formatters |
|
15 import pygments.lexers |
|
16 import pygments.util |
|
17 |
11 from mercurial import demandimport |
18 from mercurial import demandimport |
12 demandimport.ignore.extend(['pkgutil', 'pkg_resources', '__main__']) |
19 demandimport.ignore.extend(['pkgutil', 'pkg_resources', '__main__']) |
13 from mercurial import util, encoding |
|
14 |
20 |
15 from pygments import highlight |
21 from mercurial import ( |
16 from pygments.util import ClassNotFound |
22 encoding, |
17 from pygments.lexers import guess_lexer, guess_lexer_for_filename, TextLexer |
23 util, |
18 from pygments.formatters import HtmlFormatter |
24 ) |
|
25 |
|
26 highlight = pygments.highlight |
|
27 ClassNotFound = pygments.util.ClassNotFound |
|
28 guess_lexer = pygments.lexers.guess_lexer |
|
29 guess_lexer_for_filename = pygments.lexers.guess_lexer_for_filename |
|
30 TextLexer = pygments.lexers.TextLexer |
|
31 HtmlFormatter = pygments.formatters.HtmlFormatter |
19 |
32 |
20 SYNTAX_CSS = ('\n<link rel="stylesheet" href="{url}highlightcss" ' |
33 SYNTAX_CSS = ('\n<link rel="stylesheet" href="{url}highlightcss" ' |
21 'type="text/css" />') |
34 'type="text/css" />') |
22 |
35 |
23 def pygmentize(field, fctx, style, tmpl, guessfilenameonly=False): |
36 def pygmentize(field, fctx, style, tmpl, guessfilenameonly=False): |