diff options
author | facelessuser <faceless.shop@gmail.com> | 2014-10-04 17:09:31 -0600 |
---|---|---|
committer | facelessuser <faceless.shop@gmail.com> | 2014-10-04 17:09:31 -0600 |
commit | 5a44ed959880b73561dc97212a1286d47c7d40f0 (patch) | |
tree | f35a0b944f85ba671372ddabf5e06258a33f26fc | |
parent | f0c5b71acbc02af60a33d67c59558bb513b25e74 (diff) | |
download | markdown-5a44ed959880b73561dc97212a1286d47c7d40f0.tar.gz markdown-5a44ed959880b73561dc97212a1286d47c7d40f0.tar.bz2 markdown-5a44ed959880b73561dc97212a1286d47c7d40f0.zip |
Use Pygments API
-rw-r--r-- | markdown/extensions/codehilite.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/markdown/extensions/codehilite.py b/markdown/extensions/codehilite.py index 7fbf83f..0c3df7e 100644 --- a/markdown/extensions/codehilite.py +++ b/markdown/extensions/codehilite.py @@ -22,8 +22,8 @@ from ..treeprocessors import Treeprocessor import warnings try: from pygments import highlight - from pygments.lexers import get_lexer_by_name, guess_lexer, TextLexer - from pygments.formatters import HtmlFormatter + from pygments.lexers import get_lexer_by_name, guess_lexer + from pygments.formatters import get_formatter_by_name pygments = True except ImportError: pygments = False @@ -109,14 +109,15 @@ class CodeHilite(object): if self.guess_lang: lexer = guess_lexer(self.src) else: - lexer = TextLexer() + lexer = get_lexer_by_name('text') except ValueError: - lexer = TextLexer() - formatter = HtmlFormatter(linenos=self.linenums, - cssclass=self.css_class, - style=self.style, - noclasses=self.noclasses, - hl_lines=self.hl_lines) + lexer = get_lexer_by_name('text') + formatter = get_formatter_by_name('html', + linenos=self.linenums, + cssclass=self.css_class, + style=self.style, + noclasses=self.noclasses, + hl_lines=self.hl_lines) return highlight(self.src, lexer, formatter) else: # just escape and build markup usable by JS highlighting libs @@ -247,4 +248,3 @@ class CodeHiliteExtension(Extension): def makeExtension(*args, **kwargs): return CodeHiliteExtension(*args, **kwargs) - |