From cf7cc38bd8b4419226df2825280df4fc44c92cb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Mart=C3=ADnez=20Portela?= Date: Sun, 28 Aug 2022 14:09:57 +0200 Subject: [PATCH] Render titles with markup. --- scripts/generate.py | 15 ++++++++++++--- static/style.css | 5 ++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/scripts/generate.py b/scripts/generate.py index 01aef10..280957e 100644 --- a/scripts/generate.py +++ b/scripts/generate.py @@ -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('') 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('
') @@ -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):

{state} - {html.escape(headline.title)} + {render_inline(headline.title, render_tag)}

diff --git a/static/style.css b/static/style.css index 032e9dc..c220b9a 100644 --- a/static/style.css +++ b/static/style.css @@ -29,11 +29,14 @@ html, body { content: "🮦"; } -/* Inhibit

tags inside items */ +/* Inhibit

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 {