mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-11-15 16:12:51 +11:00
Pygments 0.6 downgrade.
This commit is contained in:
parent
2734acb627
commit
db0e060b30
1 changed files with 4 additions and 6 deletions
|
@ -1,7 +1,5 @@
|
||||||
from pygments.lexers import get_all_lexers, get_lexer_by_name, guess_lexer, PythonLexer
|
from pygments.lexers import get_all_lexers, get_lexer_by_name, guess_lexer, PythonLexer
|
||||||
from pygments.styles import get_all_styles
|
|
||||||
from pygments.formatters import HtmlFormatter
|
from pygments.formatters import HtmlFormatter
|
||||||
from pygments.util import ClassNotFound
|
|
||||||
from pygments import highlight
|
from pygments import highlight
|
||||||
|
|
||||||
from django.utils.html import escape
|
from django.utils.html import escape
|
||||||
|
@ -41,7 +39,7 @@ class NakedHtmlFormatter(HtmlFormatter):
|
||||||
def pygmentize(code_string, lexer_name=LEXER_DEFAULT):
|
def pygmentize(code_string, lexer_name=LEXER_DEFAULT):
|
||||||
try:
|
try:
|
||||||
lexer = get_lexer_by_name(lexer_name)
|
lexer = get_lexer_by_name(lexer_name)
|
||||||
except ClassNotFound:
|
except ValueError:
|
||||||
logger.warning('Could not find lexer for name "%s"' % lexer_name)
|
logger.warning('Could not find lexer for name "%s"' % lexer_name)
|
||||||
lexer = PythonLexer()
|
lexer = PythonLexer()
|
||||||
|
|
||||||
|
@ -54,5 +52,5 @@ def pygmentize(code_string, lexer_name=LEXER_DEFAULT):
|
||||||
def guess_code_lexer(code_string, default_lexer='unknown'):
|
def guess_code_lexer(code_string, default_lexer='unknown'):
|
||||||
try:
|
try:
|
||||||
return guess_lexer(code_string).name
|
return guess_lexer(code_string).name
|
||||||
except ClassNotFound:
|
except ValueError:
|
||||||
return default_lexer
|
return default_lexer
|
||||||
|
|
Loading…
Reference in a new issue