Improved table support to handle basic headers.
This commit is contained in:
parent
760b0b0913
commit
9bd5739b13
|
@ -47,8 +47,7 @@ def parse_text_html(doc, token, cls="", root=True):
|
||||||
|
|
||||||
def blockquote(doc, token, cls="", root=True):
|
def blockquote(doc, token, cls="", root=True):
|
||||||
return "<blockquote%s>%s</blockquote>\n" % (
|
return "<blockquote%s>%s</blockquote>\n" % (
|
||||||
cls,
|
cls, escape(token.value).replace("\n", "<br />")
|
||||||
escape(token.value).replace("\n", "<br />"),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,10 +59,23 @@ def header(doc, item, cls="", root=True):
|
||||||
|
|
||||||
|
|
||||||
def table(doc, item, cls="", root=True):
|
def table(doc, item, cls="", root=True):
|
||||||
tbl = ""
|
tbl = "<tbody>"
|
||||||
|
tblhead = ""
|
||||||
|
newrow = None
|
||||||
for row in item.value.split("\n"):
|
for row in item.value.split("\n"):
|
||||||
tbl += "<tr>" + "</td><td>".join(row.split("|")) + "</tr>\n"
|
if newrow:
|
||||||
return "<table%s%s>%s</table%s>\n" % (depth, cls, tbl, depth)
|
if row.startswith("|-"):
|
||||||
|
tblhead += "<thead><th>" + "</th><th>".join(
|
||||||
|
newrow
|
||||||
|
) + "</th></thead>\n"
|
||||||
|
else:
|
||||||
|
tbl += f"<tr><td>" + "</td><td>".join(newrow) + "</td></tr>\n"
|
||||||
|
newrow = filter(None, row.split("|"))
|
||||||
|
if row.startswith("|-"):
|
||||||
|
newrow = None
|
||||||
|
|
||||||
|
tbl += "</tbody>"
|
||||||
|
return "<table%s>%s%s</table>\n" % (cls, tblhead, tbl)
|
||||||
|
|
||||||
|
|
||||||
builddoc = {
|
builddoc = {
|
||||||
|
|
Loading…
Reference in New Issue