Fix a little bug due to <pre> tag in <dyn:code>
This commit is contained in:
parent
44800ac42c
commit
a6f66afbac
|
@ -237,12 +237,19 @@ class Index(DynastieGenerator):
|
||||||
formatter.encoding = 'utf-8'
|
formatter.encoding = 'utf-8'
|
||||||
|
|
||||||
writer = StrictUTF8Writer()
|
writer = StrictUTF8Writer()
|
||||||
node.firstChild.firstChild.writexml(writer)
|
node.writexml(writer)
|
||||||
code = writer.getvalue().encode('utf-8')
|
code = writer.getvalue().encode('utf-8')
|
||||||
|
|
||||||
|
start = code.find('<pre>');
|
||||||
|
end = code.rfind('</pre>');
|
||||||
|
|
||||||
|
if start == -1 or end == -1 or end < start:
|
||||||
|
self.addError('Error parsing <dyn:code>')
|
||||||
|
return ''
|
||||||
|
|
||||||
r,w = os.pipe()
|
r,w = os.pipe()
|
||||||
r,w=os.fdopen(r,'r',0), os.fdopen(w,'w',0)
|
r,w=os.fdopen(r,'r',0), os.fdopen(w,'w',0)
|
||||||
highlight(code, lexer, formatter, w)
|
highlight(code[start+5:end], lexer, formatter, w)
|
||||||
w.close()
|
w.close()
|
||||||
|
|
||||||
code = r.read()
|
code = r.read()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user