From 81e6935157fe4b83ab95021ca33ea1a788b4bc58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Mart=C3=ADnez=20Portela?= Date: Sat, 7 May 2022 23:03:26 +0200 Subject: [PATCH] Generate code blocks. --- _scripts/generate.py | 13 ++++++++++++- static/style.css | 27 +++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/_scripts/generate.py b/_scripts/generate.py index 8bde3a5..7635953 100644 --- a/_scripts/generate.py +++ b/_scripts/generate.py @@ -7,6 +7,7 @@ import sys import uuid from datetime import datetime +import org_rw from org_rw import OrgTime, dom, Link from org_rw import dump as dump_org from org_rw import load as load_org @@ -152,7 +153,17 @@ def render_list_item(element, acc): def render_code_block(element, acc): - pass + acc.append('
')
+    for line in element.lines:
+        if isinstance(line, org_rw.org_rw.Text):
+            for tok in line.contents:
+                if not isinstance(tok, org_rw.org_rw.MarkerToken):
+                    acc.append(tok)
+        elif isinstance(line, dom.CodeBlock):
+            print(line.lines)
+        else:
+            print(type(line))
+    acc.append('
') def render_text(element, acc): diff --git a/static/style.css b/static/style.css index 3ca95d9..656ff1b 100644 --- a/static/style.css +++ b/static/style.css @@ -1,10 +1,9 @@ -/* Any node */ +/* Node styling */ .node { max-width: min(650px, 100ex); margin: 0 auto; } -/* Inner node */ .node .node { margin: 2em 0ex 2em 0.5ex; padding: 1ex 0 1ex 1ex; @@ -24,6 +23,7 @@ content: "🮦"; } +/* Headers */ h1 { font-size: 150%; } @@ -47,6 +47,7 @@ h1.title .state { border-radius: 5px; } +/* Lists */ li .tag { font-weight: bold; } @@ -54,3 +55,25 @@ li .tag { li .tag::after { content: ":: "; } + +/* Code blocks */ +pre { + overflow: auto; + padding: 0.5ex; + padding-left: 0.5ex; + padding-left: 1.5ex; + background-color: #eee8d5; + box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.26); +} +pre > code { + display: block; + line-height: 1.2em; + overflow: auto; +} +code { + padding: 0.5ex; + font-size: medium; + border: 2px solid #eee8d5; + background: #fdf6e3; + color: #073642; +}