Make inline slide components work again

This commit is contained in:
Knoch 2023-01-10 15:29:05 +01:00
parent f0689888d4
commit eb0aec2cd3
2 changed files with 16 additions and 5 deletions

View File

@ -14,6 +14,7 @@ FRAGMENT_CLASS = "fragment"
def defragmentize(html):
dom = etree.fromstring(html)
query = "|".join([
# FRAGMENT_TAG between two spaces
"//*[contains(text(), ' %s ')]" % FRAGMENT_TAG,
@ -33,7 +34,7 @@ def defragmentize(html):
fragment.set('class', class_list)
fragment.text = re.sub(r"\s*%s\s*" %
re.escape(FRAGMENT_TAG), '', fragment.text)
re.escape(FRAGMENT_TAG), '', fragment.text)
return etree.tostring(dom, method='html', encoding='utf-8',
pretty_print=True).decode('utf-8')

View File

@ -14,17 +14,27 @@ def compile_slide(slide, root_directory):
slide_metadata = get_slide_metadata(slide)
slide_data = get_slide_data(slide)
slide = get_slide_layout(slide_metadata['layout'])
if 'todo' in slide_data.keys():
# TODO: Move the css into a global onpoint.css file
slide = '<aside class="todo" style="position:absolute; z-index:100; display:block; background:rgba(255,0,0,.8); top:0; right:0; max-width:20%; margin:.5em; padding:.5em; border-radius:1em; font-family:sans-serif; font-size: .8em;">@todo</aside>' + slide
for key, value in slide_data.items():
placeholder = '@' + key
filler = convert_slide_content(value)
# print('replace', placeholder, 'with', filler)
if '@' + key in slide:
# very unelegant attempt at inline elements
inline_key = '@' + key + '(inline)'
if inline_key in slide:
slide = slide.replace(
inline_key,
re.sub(r"<p>(.+)</p>", r"\1", filler)
)
elif '@' + key in slide:
slide = slide.replace(placeholder, filler)
# very unelegant attempt at inline elements
slide = re.sub(r"<p>(.+?)</p>\n\(inline\)", r"\1", slide)
return slide
# Parses the metadata passage of a given slide and returns the metadata as a