|
@@ -19,6 +19,9 @@ page_stack[0].head_html += docutils.core.publish_parts('', writer_name='html')['
|
|
|
def example(content: Union[Element, str]):
|
|
|
callFrame = inspect.currentframe().f_back.f_back
|
|
|
begin = callFrame.f_lineno
|
|
|
+ def generateIdFromHeadline(html):
|
|
|
+ match = re.search(r'<h3.*?>(.*?)</h3>', html)
|
|
|
+ return re.sub('[^(a-z)(A-Z)(0-9)._-]', '', match.groups()[0].strip()) if match else ''
|
|
|
with ui.row().classes('flex w-full'):
|
|
|
if isinstance(content, str):
|
|
|
ui.markdown(content).classes('mr-8 w-4/12')
|
|
@@ -28,6 +31,9 @@ def example(content: Union[Element, str]):
|
|
|
html = docutils.core.publish_parts(doc, writer_name='html')['html_body']
|
|
|
html = html.replace('<p>', '<h3>', 1)
|
|
|
html = html.replace('</p>', '</h3>', 1)
|
|
|
+ headline_id = generateIdFromHeadline(html)
|
|
|
+ if headline_id:
|
|
|
+ html = html.replace('<h3>', f'<h3 id="{id}">', 1)
|
|
|
html = Markdown.apply_tailwind(html)
|
|
|
ui.html(html).classes('mr-8 w-4/12')
|
|
|
else:
|