mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-11-15 08:02:54 +11:00
Escape unhighlighted code.
This commit is contained in:
parent
ba1798e75c
commit
4992571444
1 changed files with 3 additions and 1 deletions
|
@ -4,6 +4,8 @@ from pygments.formatters import HtmlFormatter
|
||||||
from pygments.util import ClassNotFound
|
from pygments.util import ClassNotFound
|
||||||
from pygments import highlight
|
from pygments import highlight
|
||||||
|
|
||||||
|
from django.utils.html import escape
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -47,7 +49,7 @@ def pygmentize(code_string, lexer_name='text'):
|
||||||
return highlight(code_string, lexer, NakedHtmlFormatter())
|
return highlight(code_string, lexer, NakedHtmlFormatter())
|
||||||
except TypeError:
|
except TypeError:
|
||||||
logger.warning('Could not highlight code with lexer "%s"' % lexer_name)
|
logger.warning('Could not highlight code with lexer "%s"' % lexer_name)
|
||||||
return code_string
|
return escape(code_string)
|
||||||
|
|
||||||
def guess_code_lexer(code_string, default_lexer='unknown'):
|
def guess_code_lexer(code_string, default_lexer='unknown'):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue