minirst: optimize HTML table generation a bit

avoid a couple of array copies and string interpolations
This commit is contained in:
Dan Villiom Podlaski Christiansen 2013-02-09 21:51:21 +00:00
parent e6781fbadb
commit 17ccef70f8

View File

@ -559,13 +559,17 @@ def formathtml(blocks):
out.append('<h%d>%s</h%d>\n' % (level, escape(lines[0]), level))
elif btype == 'table':
table = b['table']
t = []
out.append('<table>\n')
for row in table:
l = []
out.append('<tr>')
for v in row:
l.append('<td>%s</td>' % escape(v))
t.append('<tr>%s</tr>\n' % '\n'.join(l))
out.append('<table>\n%s</table>\n' % ''.join(t))
out.append('<td>')
out.append(escape(v))
out.append('</td>')
out.append('\n')
out.pop()
out.append('</tr>\n')
out.append('</table>\n')
elif btype == 'definition':
openlist('dl', level)
term = escape(lines[0])