@@ -118,11 +118,11 @@ def image_path(image_name: str, tex_file: str) -> Optional[str]:
118118def filter (
119119 func : Callable [
120120 [pf .Element , pf .elements .Doc , Set , bool ],
121- Optional [pf .Str ],
121+ Optional [pf .Inline ],
122122 ]
123123) -> Callable [
124124 [pf .Element , pf .elements .Doc , Set , str , bool ],
125- Optional [pf .Str ],
125+ Optional [pf .Inline ],
126126]:
127127 """Python decorator to make generic LaTeX elements markdown readable.
128128
@@ -139,7 +139,7 @@ def markdown_converter(
139139 set : Set ,
140140 tex_file : str ,
141141 parsing_answers : bool ,
142- ) -> Optional [pf .Str ]:
142+ ) -> Optional [pf .Inline ]:
143143 """Handles LaTeX elements within the filter, before calling the original function.
144144
145145 N.B. tex_file is required to determine where the relative image directory is.
@@ -163,10 +163,13 @@ def markdown_converter(
163163 expression = latex_to_katex (elem .text )
164164 except Exception :
165165 expression = elem .text
166- return pf .Str (
167- f"${ expression } $"
168- if elem .format == "InlineMath"
169- else f"\n \n $$\n { expression } \n $$\n \n "
166+ return pf .RawInline (
167+ (
168+ f"${ expression } $"
169+ if elem .format == "InlineMath"
170+ else f"\n \n $$\n { expression } \n $$\n \n "
171+ ),
172+ format = "markdown" ,
170173 )
171174
172175 case pf .Image :
@@ -176,13 +179,13 @@ def markdown_converter(
176179 echo (f"Warning: Couldn't find { elem .url } " )
177180 else :
178181 set .current_question .images .append (path )
179- return pf .Str (f"" )
182+ return pf .RawInline (f"" , format = "markdown " )
180183
181184 case pf .Strong :
182- return pf .Str (f"**{ pf .stringify (elem )} **" )
185+ return pf .RawInline (f"**{ pf .stringify (elem )} **" , format = "markdown " )
183186
184187 case pf .Emph :
185- return pf .Str (f"*{ pf .stringify (elem )} *" )
188+ return pf .RawInline (f"*{ pf .stringify (elem )} *" , format = "markdown " )
186189
187190 # Replace siunitx no-break space with narrow no-break space
188191 # This should be the space between the number and the units
0 commit comments