Render titles with markup.

This commit is contained in:
Sergio Martínez Portela 2022-08-28 14:09:57 +02:00
parent 89bf34ed46
commit cf7cc38bd8
2 changed files with 16 additions and 4 deletions

View File

@ -88,7 +88,7 @@ def regen_all(src_top, dest_top, docs=None):
while i > 0:
i -= 1
headline = headlines[i]
if headline.title.strip().lower() == "related" and headline.depth == 1:
if headline.title.get_text().strip().lower() == "related" and headline.depth == 1:
if related is not None:
print(
"Found duplicated related: {} vs {}".format(
@ -170,7 +170,7 @@ def regen_all(src_top, dest_top, docs=None):
"relation": "in"
})
graph[headline.id] = {
"title": headline.title.strip(),
"title": org_rw.token_list_to_plaintext(headline.title.contents).strip(),
"links": links,
"depth": headline.depth,
}
@ -311,6 +311,9 @@ def render_results_block(element, acc):
# acc.append('</code></pre>')
pass
def render_org_text(element, acc):
as_dom = org_rw.text_to_dom(element.contents, element)
render_text_tokens(as_dom, acc)
def render_text(element, acc):
acc.append('<div class="text">')
@ -350,6 +353,7 @@ def render_tag(element, acc):
dom.CodeBlock: render_code_block,
dom.Text: render_text,
dom.ResultsDrawerNode: render_results_block,
org_rw.Text: render_org_text,
}[type(element)](element, acc)
@ -357,6 +361,11 @@ def render_tree(tree, acc):
for element in tree:
render_tag(element, acc)
def render_inline(tree, f):
acc = []
f(tree, acc)
return ''.join(acc)
def render(headline, doc, headlineLevel):
try:
@ -390,7 +399,7 @@ def render(headline, doc, headlineLevel):
<h1 class="title">
{state}
<a href=\"javascript:toggle_expand('{html.escape(headline.id)}')\">
{html.escape(headline.title)}
{render_inline(headline.title, render_tag)}
</a>
</h1>
<div class='contents'>

View File

@ -29,11 +29,14 @@ html, body {
content: "🮦";
}
/* Inhibit <p> tags inside items */
/* Inhibit <p> tags inside inlined items */
/* TODO: Remove need for this on generator */
.item p {
display: inline;
}
h1 p,h2 p,h3 p,h4 p,h5 p,h6 p {
display: inline;
}
/* Headers */
body > .node > h1 {