diff --git a/fragments.py b/fragments.py index f9b49e8..89e90ed 100644 --- a/fragments.py +++ b/fragments.py @@ -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') diff --git a/slides.py b/slides.py index c735e89..f54cad8 100644 --- a/slides.py +++ b/slides.py @@ -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 = '' + 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"

(.+)

", r"\1", filler) + ) + + elif '@' + key in slide: slide = slide.replace(placeholder, filler) - # very unelegant attempt at inline elements - slide = re.sub(r"

(.+?)

\n\(inline\)", r"\1", slide) + + return slide # Parses the metadata passage of a given slide and returns the metadata as a