Add result box rendering.
This commit is contained in:
parent
212c41d848
commit
76531e3cfc
@ -11,6 +11,7 @@ import uuid
|
||||
from datetime import datetime
|
||||
import traceback
|
||||
import re
|
||||
from itertools import chain
|
||||
|
||||
import inotify.adapters
|
||||
|
||||
@ -399,10 +400,10 @@ def render_list_item(element, acc, headline, graph):
|
||||
render_text_tokens(element.content, acc, headline, graph)
|
||||
acc.append("</span></li>")
|
||||
|
||||
|
||||
def render_code_block(element, acc, headline, graph):
|
||||
acc.append('<pre class="{}"><code>'.format(element.subtype.lower()))
|
||||
content = html.escape(element.lines)
|
||||
def render_block(content, acc, _class, is_code):
|
||||
acc.append('<pre class="{}">'.format(_class))
|
||||
if is_code:
|
||||
acc.append('<code>')
|
||||
|
||||
# Remove indentation common to all lines
|
||||
base_indentation = min([
|
||||
@ -416,14 +417,21 @@ def render_code_block(element, acc, headline, graph):
|
||||
]
|
||||
|
||||
acc.append('\n'.join(content_lines))
|
||||
acc.append('</code></pre>')
|
||||
if is_code:
|
||||
acc.append('</code>')
|
||||
acc.append('</pre>')
|
||||
|
||||
def render_code_block(element, acc, headline, graph):
|
||||
content = html.escape(element.lines)
|
||||
render_block(content, acc, _class='code ' + element.subtype.lower(), is_code=True)
|
||||
|
||||
|
||||
def render_results_block(element, acc, headline, graph):
|
||||
# TODO:
|
||||
# acc.append('<pre class="results"><code>')
|
||||
# render_tree(element.children, acc)
|
||||
# acc.append('</code></pre>')
|
||||
pass
|
||||
items = [e.get_raw() for e in element.children]
|
||||
print(items)
|
||||
content = '\n'.join(items)
|
||||
if len(content.strip()) > 0:
|
||||
render_block(content, acc, _class='results lang-text', is_code=False)
|
||||
|
||||
def render_org_text(element, acc, headline, graph):
|
||||
as_dom = org_rw.text_to_dom(element.contents, element)
|
||||
@ -436,6 +444,8 @@ def render_text(element, acc, headline, graph):
|
||||
|
||||
def render_text_tokens(tokens, acc, headline, graph):
|
||||
acc.append('<p>')
|
||||
if isinstance(tokens, org_rw.Text):
|
||||
tokens = tokens.contents
|
||||
for chunk in tokens:
|
||||
if isinstance(chunk, str):
|
||||
lines = chunk.split('\n\n')
|
||||
|
Loading…
Reference in New Issue
Block a user