Commit 128f1d77 authored by Stefan Behnel's avatar Stefan Behnel

fix some HTML issues in annotation file

parent 57cbbc21
...@@ -11,9 +11,11 @@ from Code import CCodeWriter ...@@ -11,9 +11,11 @@ from Code import CCodeWriter
from Cython import Utils from Cython import Utils
# 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'\xF0', u'&lt;'), special_chars = [
(u'&', u'\xF2', u'&amp;'),
(u'<', u'\xF0', u'&lt;'),
(u'>', u'\xF1', u'&gt;'), (u'>', u'\xF1', u'&gt;'),
(u'&', u'\xF2', u'&amp;')] ]
line_pos_comment = re.compile(r'/\*.*?<<<<<<<<<<<<<<.*?\*/\n*', re.DOTALL) line_pos_comment = re.compile(r'/\*.*?<<<<<<<<<<<<<<.*?\*/\n*', re.DOTALL)
...@@ -57,8 +59,7 @@ class AnnotationCCodeWriter(CCodeWriter): ...@@ -57,8 +59,7 @@ class AnnotationCCodeWriter(CCodeWriter):
self.mark_pos(None) self.mark_pos(None)
f = Utils.open_source_file(source_filename) f = Utils.open_source_file(source_filename)
lines = f.readlines() lines = f.readlines()
for k in range(len(lines)): for k, line in enumerate(lines):
line = lines[k]
for c, cc, html in special_chars: for c, cc, html in special_chars:
line = line.replace(c, cc) line = line.replace(c, cc)
lines[k] = line lines[k] = line
...@@ -86,6 +87,7 @@ class AnnotationCCodeWriter(CCodeWriter): ...@@ -86,6 +87,7 @@ class AnnotationCCodeWriter(CCodeWriter):
html_filename = os.path.splitext(target_filename)[0] + ".html" html_filename = os.path.splitext(target_filename)[0] + ".html"
f = codecs.open(html_filename, "w", encoding="UTF-8") f = codecs.open(html_filename, "w", encoding="UTF-8")
f.write(u'<!DOCTYPE html>\n')
f.write(u'<!-- Generated by Cython %s -->\n' % Version.watermark) f.write(u'<!-- Generated by Cython %s -->\n' % Version.watermark)
f.write(u'<html>\n') f.write(u'<html>\n')
f.write(u""" f.write(u"""
...@@ -147,8 +149,9 @@ function toggleDiv(id) { ...@@ -147,8 +149,9 @@ function toggleDiv(id) {
code = code_source_file[k] code = code_source_file[k]
except KeyError: except KeyError:
code = '' code = ''
else:
code = code.replace('<', '<code><</code>') for c, cc, html in special_chars:
code = code.replace(c, html)
code, py_c_api_calls = py_c_api.subn(ur"<span class='py_c_api'>\1</span>(", code) code, py_c_api_calls = py_c_api.subn(ur"<span class='py_c_api'>\1</span>(", code)
code, pyx_c_api_calls = pyx_c_api.subn(ur"<span class='pyx_c_api'>\1</span>(", code) code, pyx_c_api_calls = pyx_c_api.subn(ur"<span class='pyx_c_api'>\1</span>(", code)
......
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