mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-11-15 16:12:51 +11:00
Fixed a bug that raised an error if a lexer is unknown
This commit is contained in:
parent
e34c46f9aa
commit
bf39d704d7
1 changed files with 5 additions and 2 deletions
|
@ -107,6 +107,9 @@ class NakedHtmlFormatter(HtmlFormatter):
|
|||
yield i, t
|
||||
|
||||
def pygmentize(code_string, lexer_name=LEXER_DEFAULT):
|
||||
lexer = lexer_name and get_lexer_by_name(lexer_name) \
|
||||
or PythonLexer()
|
||||
try:
|
||||
lexer = lexer_name and get_lexer_by_name(lexer_name) \
|
||||
or PythonLexer()
|
||||
except Exception as e:
|
||||
lexer = PythonLexer()
|
||||
return highlight(code_string, lexer, NakedHtmlFormatter())
|
||||
|
|
Loading…
Reference in a new issue