def generate_document_from_row_list(title, header, row_list):
"""Create HTML5 document from a table.
Args:
title: Title of html document.
row_list: Table with the data to generate the document.
"""
doc, tag, text = Doc().tagtext()
doc.asis("<!DOCTYPE html>")
with tag("html"):
with tag("head"):
doc.asis("<meta charset=\"utf-8\">")
with tag("title"):
text(title)
with tag("body"):
with tag("h1"):
text(title)
if (header is not None):
with tag("h3"):
text(header)
with tag("table", border="1"):
for r in row_list:
num_cols = len(r)
with tag("tr"):
for i in range(num_cols):
with tag("td"):
if r[i] is None:
text("")
elif unicode(r[i]).encode(
"unicode-escape").startswith("<img"):
doc.asis(r[i])
else:
text(r[i])
return doc.getvalue()
评论列表
文章目录