Render note tables.

This commit is contained in:
Sergio Martínez Portela 2022-09-28 00:04:06 +02:00
parent f6254a6c53
commit cc8d7d0bc5
2 changed files with 37 additions and 0 deletions

View File

@ -276,6 +276,21 @@ def render_list_group(element, acc):
render_tree(element.children, acc) render_tree(element.children, acc)
acc.append("</ul>") acc.append("</ul>")
def render_table(element, acc):
acc.append("<table>")
render_tree(element.children, acc)
acc.append("</table>")
def render_table_row(element, acc):
acc.append("<tr>")
for cell in element.cells:
acc.append("<td>")
acc.append(html.escape(cell))
acc.append("</td>")
acc.append("</tr>")
def render_table_separator_row(element, acc):
acc.append("<tr class='__table-separator'></tr>")
def render_list_item(element, acc): def render_list_item(element, acc):
acc.append("<li>") acc.append("<li>")
@ -353,6 +368,9 @@ def render_tag(element, acc):
dom.PropertyNode: render_property_node, dom.PropertyNode: render_property_node,
dom.ListGroupNode: render_list_group, dom.ListGroupNode: render_list_group,
dom.ListItem: render_list_item, dom.ListItem: render_list_item,
dom.TableNode: render_table,
dom.TableSeparatorRow: render_table_separator_row,
dom.TableRow: render_table_row,
dom.CodeBlock: render_code_block, dom.CodeBlock: render_code_block,
dom.Text: render_text, dom.Text: render_text,
dom.ResultsDrawerNode: render_results_block, dom.ResultsDrawerNode: render_results_block,

View File

@ -189,6 +189,17 @@ article.post {
border-bottom: #000 1px dashed; border-bottom: #000 1px dashed;
} }
/* Tables. */
table, th, td, tr {
border: 1px solid black;
border-collapse: collapse;
}
td {
padding: 0.5ex;
}
tr.__table-separator {
border-bottom: 0.5ex solid black;
}
/* Dark mode. */ /* Dark mode. */
@media (prefers-color-scheme: dark) { @media (prefers-color-scheme: dark) {
@ -236,4 +247,12 @@ article.post {
color: #FFF; color: #FFF;
font-family: Menlo, Monaco, "Courier New", monospace; font-family: Menlo, Monaco, "Courier New", monospace;
} }
/* Tables. */
table, th, td, tr {
border: 1px solid #eee;
}
tr.__table-separator {
border-bottom: 0.5ex solid #eee;
}
} }