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