Generate code blocks.

This commit is contained in:
Sergio Martínez Portela 2022-05-07 23:03:26 +02:00
parent 8698035f2e
commit 81e6935157
2 changed files with 37 additions and 3 deletions

View File

@ -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('<pre><code>')
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('</code></pre>')
def render_text(element, acc):

View File

@ -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;
}