Invert <dyn:code> and <pre> tags

This commit is contained in:
2012-11-19 19:11:04 +01:00
parent 16c2c73389
commit 08f1747505
2 changed files with 7 additions and 10 deletions

View File

@@ -239,24 +239,21 @@ class Index(DynastieGenerator):
formatter.encoding = 'utf-8'
writer = StrictUTF8Writer()
node.writexml(writer)
node.firstChild.writexml(writer)
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.fdopen(r,'r',0), os.fdopen(w,'w',0)
highlight(code[start+5:end], lexer, formatter, w)
highlight(code, lexer, formatter, w)
w.close()
code = r.read()
r.close()
# Remove <pre> after <div class="highlight">
code = code[28:-13]
code = '<div class="highlight">' + code + '</div>'
return code
def generate(self, blog, src, output):