1+ import re
12from string import whitespace
23from urllib .parse import urlparse
34from xml .etree import ElementTree
78from tablerpy import OutlineIcon , get_icon
89from marko import Markdown
910from marko .ext .gfm import GFM
10- from marko .helpers import MarkoExtension
11+ from marko .helpers import MarkoExtension , render_dispatch
12+ from marko .html_renderer import HTMLRenderer
1113
1214
1315# SVG namespace
@@ -24,8 +26,10 @@ def icon(icon_name, a11y_title):
2426 with open (icon_path , "rt" ) as icon_ref :
2527 svg_string = icon_ref .read ()
2628 root = ElementTree .fromstring (svg_string )
27- root .insert (0 , ElementTree .fromstring (f"<title>{ a11y_title } </title>" ))
28- return ElementTree .tostring (root , encoding = "unicode" )
29+ title = ElementTree .fromstring (f"<title>{ a11y_title } </title>" )
30+ root .insert (0 , title )
31+ svg = ElementTree .tostring (root , encoding = "unicode" )
32+ return svg
2933
3034
3135def h2_and_rest (markdown ):
@@ -81,6 +85,16 @@ def render_page(page_data, template_filename):
8185
8286# Marko extension
8387class MeteorRendererMixin (object ):
88+ # Override the lists of escaped elements to omit `title` since it is used in inline SVGs
89+ tagfilter = re .compile (
90+ r"<(textarea|style|xmp|iframe|noembed|noframes|script|plaintext)" ,
91+ flags = re .I ,
92+ )
93+ tagfilter_no_open = re .compile (
94+ r"(?<!^)( *)<(textarea|style|xmp|iframe|noembed|noframes|script|plaintext)" ,
95+ flags = re .I ,
96+ )
97+
8498 def render_link (self , element ):
8599 # From overwritten function
86100 title = f' title="{ self .escape_html (element .title )} "' if element .title else ""
@@ -109,5 +123,5 @@ def render_link(self, element):
109123# Marko renderer callback for Ark
110124@ark .renderers .register ("md" )
111125def render_markdown (text ):
112- markdown = Markdown (extensions = [MeteorExtension , GFM ])
126+ markdown = Markdown (extensions = [GFM , MeteorExtension ])
113127 return markdown (text )
0 commit comments