minor few fix

This commit is contained in:
ilvalle committed 2016-06-10 14:14:40 +02:00
1 parent 3103226686
commit 1f013d76f3
13 files changed
+46 -43

No files matched your search

+6 -7
View File
@@ -7,9 +7,8 @@
| License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
"""
from __future__ import print_function
from gluon._compat import xrange
from gluon._compat import xrange, _local_html_escape
import re
import cgi
__all__ = ['highlight']
@@ -63,7 +62,7 @@ class Highlighter(object):
Callback for C specific highlighting.
"""
value = cgi.escape(match.group())
value = _local_html_escape(match.group(), quote=False)
self.change_style(token, style)
self.output.append(value)
@@ -77,7 +76,7 @@ class Highlighter(object):
Callback for python specific highlighting.
"""
value = cgi.escape(match.group())
value = _local_html_escape(match.group(), quote=False)
if token == 'MULTILINESTRING':
self.change_style(token, style)
self.output.append(value)
@@ -114,7 +113,7 @@ class Highlighter(object):
Callback for HTML specific highlighting.
"""
value = cgi.escape(match.group())
value = _local_html_escape(match.group(), quote=False)
self.change_style(token, style)
self.output.append(value)
if token == 'GOTOPYTHON':
@@ -292,13 +291,13 @@ def highlight(
'WEB2PY']:
code = Highlighter(language, link, styles).highlight(code)
else:
code = cgi.escape(code)
code = _local_html_escape(code, quote=False)
lines = code.split('\n')
if counter is None:
linenumbers = [''] * len(lines)
elif isinstance(counter, str):
linenumbers = [cgi.escape(counter)] * len(lines)
linenumbers = [_local_html_escape(counter, quote=False)] * len(lines)
else:
linenumbers = [str(i + counter) + '.' for i in
xrange(len(lines))]