From cc8d7d0bc5242cf8d71b3621a4d6b11763686e99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Mart=C3=ADnez=20Portela?= Date: Wed, 28 Sep 2022 00:04:06 +0200 Subject: [PATCH] Render note tables. --- scripts/generate.py | 18 ++++++++++++++++++ static/style.css | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/scripts/generate.py b/scripts/generate.py index 22651ae..96c19d9 100644 --- a/scripts/generate.py +++ b/scripts/generate.py @@ -276,6 +276,21 @@ def render_list_group(element, acc): render_tree(element.children, acc) acc.append("") +def render_table(element, acc): + acc.append("") + render_tree(element.children, acc) + acc.append("
") + +def render_table_row(element, acc): + acc.append("") + for cell in element.cells: + acc.append("") + acc.append(html.escape(cell)) + acc.append("") + acc.append("") + +def render_table_separator_row(element, acc): + acc.append("") def render_list_item(element, acc): acc.append("
  • ") @@ -353,6 +368,9 @@ def render_tag(element, acc): dom.PropertyNode: render_property_node, dom.ListGroupNode: render_list_group, 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.Text: render_text, dom.ResultsDrawerNode: render_results_block, diff --git a/static/style.css b/static/style.css index 9b37fde..f0c167d 100644 --- a/static/style.css +++ b/static/style.css @@ -189,6 +189,17 @@ article.post { 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. */ @media (prefers-color-scheme: dark) { @@ -236,4 +247,12 @@ article.post { color: #FFF; 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; + } }