@@ -86,7 +86,7 @@ class RuleDictType(_RuleDictReqType, total=False):
8686
8787def applyRule (
8888 rule : RuleDictType , string : str , begin : int , inBlockquote : bool
89- ) -> None | Match [str ]:
89+ ) -> Match [str ] | None :
9090 if not (
9191 string .startswith (rule ["tag" ], begin )
9292 and (rule ["pre" ](string , begin ) if "pre" in rule else True )
@@ -210,14 +210,15 @@ def render(tex: str, displayMode: bool, macros: Any) -> str:
210210 {
211211 "name" : "math_block_eqno" ,
212212 "rex" : re .compile (
213- r"^\\\[(((?!\\\]|\\\[)[\s\S])+?)\\\]\s*?\(([^)$\r\n]+?)\)" , re .M
213+ r"^\\\[(((?!\\\]|\\\[)[\s\S])+?)\\\]\s*?\(([^)$\r\n]+?)\)" ,
214+ re .MULTILINE ,
214215 ),
215216 "tmpl" : '<section class="eqno"><eqn>{0}</eqn><span>({1})</span></section>' ,
216217 "tag" : "\\ [" ,
217218 },
218219 {
219220 "name" : "math_block" ,
220- "rex" : re .compile (r"^\\\[([\s\S]+?)\\\]" , re .M ),
221+ "rex" : re .compile (r"^\\\[([\s\S]+?)\\\]" , re .MULTILINE ),
221222 "tmpl" : "<section>\n <eqn>{0}</eqn>\n </section>\n " ,
222223 "tag" : "\\ [" ,
223224 },
@@ -237,15 +238,15 @@ def render(tex: str, displayMode: bool, macros: Any) -> str:
237238 "name" : "math_block_eqno" ,
238239 "rex" : re .compile (
239240 r"^`{3}math\s(\s*[^`\s](?:[^`]*[^`\s])?|\s)\s+`{3}\s*?\(([^)$\r\n]+?)\)" ,
240- re .M ,
241+ re .MULTILINE ,
241242 ),
242243 "tmpl" : '<section class="eqno">\n <eqn>{0}</eqn><span>({1})</span>\n </section>\n ' ,
243244 "tag" : "```math" ,
244245 },
245246 {
246247 "name" : "math_block" ,
247248 "rex" : re .compile (
248- r"^`{3}math\s(\s*[^`\s](?:[^`]*[^`\s])?|\s)\s+`{3}" , re .M
249+ r"^`{3}math\s(\s*[^`\s](?:[^`]*[^`\s])?|\s)\s+`{3}" , re .MULTILINE
249250 ),
250251 "tmpl" : "<section>\n <eqn>{0}</eqn>\n </section>\n " ,
251252 "tag" : "```math" ,
@@ -282,15 +283,15 @@ def render(tex: str, displayMode: bool, macros: Any) -> str:
282283 "name" : "math_block_eqno" ,
283284 "rex" : re .compile (
284285 r"^`{3}math\s(\s*[^`\s](?:[^`]*[^`\s])?|\s)\s+`{3}\s*?\(([^)$\r\n]+?)\)" ,
285- re .M ,
286+ re .MULTILINE ,
286287 ),
287288 "tmpl" : '<section class="eqno"><eqn>{0}</eqn><span>({1})</span></section>' ,
288289 "tag" : "```math" ,
289290 },
290291 {
291292 "name" : "math_block" ,
292293 "rex" : re .compile (
293- r"^`{3}math\s(\s*[^`\s](?:[^`]*[^`\s])?|\s)\s+`{3}" , re .M
294+ r"^`{3}math\s(\s*[^`\s](?:[^`]*[^`\s])?|\s)\s+`{3}" , re .MULTILINE
294295 ),
295296 "tmpl" : "<section><eqn>{0}</eqn></section>" ,
296297 "tag" : "```math" ,
@@ -309,13 +310,15 @@ def render(tex: str, displayMode: bool, macros: Any) -> str:
309310 "block" : [
310311 {
311312 "name" : "math_block_eqno" ,
312- "rex" : re .compile (r"^\${2}([^$]*?)\${2}\s*?\(([^)$\r\n]+?)\)" , re .M ),
313+ "rex" : re .compile (
314+ r"^\${2}([^$]*?)\${2}\s*?\(([^)$\r\n]+?)\)" , re .MULTILINE
315+ ),
313316 "tmpl" : '<section class="eqno"><eqn>{0}</eqn><span>({1})</span></section>' ,
314317 "tag" : "$$" ,
315318 },
316319 {
317320 "name" : "math_block" ,
318- "rex" : re .compile (r"^\${2}([^$]*?)\${2}" , re .M ),
321+ "rex" : re .compile (r"^\${2}([^$]*?)\${2}" , re .MULTILINE ),
319322 "tmpl" : "<section><eqn>{0}</eqn></section>" ,
320323 "tag" : "$$" ,
321324 },
@@ -343,13 +346,15 @@ def render(tex: str, displayMode: bool, macros: Any) -> str:
343346 "block" : [
344347 {
345348 "name" : "math_block_eqno" ,
346- "rex" : re .compile (r"^\${2}([^$]*?)\${2}\s*?\(([^)$\r\n]+?)\)" , re .M ),
349+ "rex" : re .compile (
350+ r"^\${2}([^$]*?)\${2}\s*?\(([^)$\r\n]+?)\)" , re .MULTILINE
351+ ),
347352 "tmpl" : '<section class="eqno">\n <eqn>{0}</eqn><span>({1})</span>\n </section>\n ' ,
348353 "tag" : "$$" ,
349354 },
350355 {
351356 "name" : "math_block" ,
352- "rex" : re .compile (r"^\${2}([^$]*?)\${2}" , re .M ),
357+ "rex" : re .compile (r"^\${2}([^$]*?)\${2}" , re .MULTILINE ),
353358 "tmpl" : "<section>\n <eqn>{0}</eqn>\n </section>\n " ,
354359 "tag" : "$$" ,
355360 },
0 commit comments