mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-11-15 08:02:54 +11:00
Some dirty fixes for NoneType error highlighting
This commit is contained in:
parent
3a44552240
commit
a6e3a6d2ae
1 changed files with 8 additions and 1 deletions
|
@ -4,6 +4,9 @@ from pygments.formatters import HtmlFormatter
|
|||
from pygments.util import ClassNotFound
|
||||
from pygments import highlight
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
LEXER_LIST_ALL = sorted([(i[1][0], i[0]) for i in get_all_lexers()])
|
||||
LEXER_LIST = (
|
||||
('bash', 'Bash'),
|
||||
|
@ -34,7 +37,11 @@ class NakedHtmlFormatter(HtmlFormatter):
|
|||
yield i, t
|
||||
|
||||
def pygmentize(code_string, lexer_name='text'):
|
||||
return highlight(code_string, get_lexer_by_name(lexer_name), NakedHtmlFormatter())
|
||||
try:
|
||||
return highlight(code_string, get_lexer_by_name(lexer_name), NakedHtmlFormatter())
|
||||
except TypeError:
|
||||
logger.critical('Highlight failed with lexter %s' % lexer_name)
|
||||
return code_string
|
||||
|
||||
def guess_code_lexer(code_string, default_lexer='unknown'):
|
||||
try:
|
||||
|
|
Loading…
Reference in a new issue