Commit 85b455b9 authored by Matthias BUSSONNIER's avatar Matthias BUSSONNIER

reorganise block order, and cleanup now useless logic

special_char was use before for counting column offset, now removed.
replace by escape_html
parent cb66c804
...@@ -13,12 +13,6 @@ from Cython import Utils ...@@ -13,12 +13,6 @@ from Cython import Utils
from contextlib import closing from contextlib import closing
# need one-characters subsitutions (for now) so offsets aren't off # need one-characters subsitutions (for now) so offsets aren't off
special_chars = [
(u'&', u'\xF2', u'&'),
(u'<', u'\xF0', u'&lt;'),
(u'>', u'\xF1', u'&gt;'),
]
class AnnotationCCodeWriter(CCodeWriter): class AnnotationCCodeWriter(CCodeWriter):
...@@ -157,24 +151,22 @@ body { font-family: courier; font-size: 12; } ...@@ -157,24 +151,22 @@ body { font-family: courier; font-size: 12; }
def _save_annotation_body(self, lines, code_source_file , c_file=None): def _save_annotation_body(self, lines, code_source_file , c_file=None):
outlist=[] outlist=[]
self.mark_pos(None) pos_comment_marker = u'/* \N{HORIZONTAL ELLIPSIS} */\n'
for k, line in enumerate(lines):
for c, cc, html in special_chars:
line = line.replace(c, cc)
lines[k] = line
zero_calls = dict((name, 0) for name in zero_calls = dict((name, 0) for name in
'refnanny py_macro_api py_c_api pyx_macro_api pyx_c_api error_goto'.split()) 'refnanny py_macro_api py_c_api pyx_macro_api pyx_c_api error_goto'.split())
self.mark_pos(None)
def annotate(match): def annotate(match):
group_name = match.lastgroup group_name = match.lastgroup
calls[group_name] += 1 calls[group_name] += 1
return ur"<span class='cython %s'>%s</span>" % ( return ur"<span class='cython %s'>%s</span>" % (
group_name, match.group(group_name)) group_name, match.group(group_name))
pos_comment_marker = u'/* \N{HORIZONTAL ELLIPSIS} */\n'
for k, line in enumerate(lines): for k, line in enumerate(lines):
line = html_escape(line)
try: try:
code = code_source_file[k] code = code_source_file[k]
except KeyError: except KeyError:
...@@ -189,11 +181,10 @@ body { font-family: courier; font-size: 12; } ...@@ -189,11 +181,10 @@ body { font-family: courier; font-size: 12; }
code = _parse_code(annotate, code) code = _parse_code(annotate, code)
score = (5 * calls['py_c_api'] + 2 * calls['pyx_c_api'] + score = (5 * calls['py_c_api'] + 2 * calls['pyx_c_api'] +
calls['py_macro_api'] + calls['pyx_macro_api']) calls['py_macro_api'] + calls['pyx_macro_api'])
outlist.append(u"<pre class='cython line score-%s' onclick='toggleDiv(this)'>" % (score)) outlist.append(u"<pre class='cython line score-%s' onclick='toggleDiv(this)'>" % (score))
outlist.append(u" %d: " % k) outlist.append(u" %d: " % k)
for c, cc, html in special_chars:
line = line.replace(cc, html)
outlist.append(line.rstrip()) outlist.append(line.rstrip())
outlist.append(u'</pre>\n') outlist.append(u'</pre>\n')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment