@@ -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 )
@@ -202,14 +202,15 @@ def render(tex: str, displayMode: bool, macros: Any) -> str:
202202 {
203203 "name" : "math_block_eqno" ,
204204 "rex" : re .compile (
205- r"^\\\[(((?!\\\]|\\\[)[\s\S])+?)\\\]\s*?\(([^)$\r\n]+?)\)" , re .M
205+ r"^\\\[(((?!\\\]|\\\[)[\s\S])+?)\\\]\s*?\(([^)$\r\n]+?)\)" ,
206+ re .MULTILINE ,
206207 ),
207208 "tmpl" : '<section class="eqno"><eqn>{0}</eqn><span>({1})</span></section>' ,
208209 "tag" : "\\ [" ,
209210 },
210211 {
211212 "name" : "math_block" ,
212- "rex" : re .compile (r"^\\\[([\s\S]+?)\\\]" , re .M ),
213+ "rex" : re .compile (r"^\\\[([\s\S]+?)\\\]" , re .MULTILINE ),
213214 "tmpl" : "<section>\n <eqn>{0}</eqn>\n </section>\n " ,
214215 "tag" : "\\ [" ,
215216 },
@@ -228,14 +229,14 @@ def render(tex: str, displayMode: bool, macros: Any) -> str:
228229 {
229230 "name" : "math_block_eqno" ,
230231 "rex" : re .compile (
231- r"^`{3}math\s+?([^`]+?)\s+?`{3}\s*?\(([^)$\r\n]+?)\)" , re .M
232+ r"^`{3}math\s+?([^`]+?)\s+?`{3}\s*?\(([^)$\r\n]+?)\)" , re .MULTILINE
232233 ),
233234 "tmpl" : '<section class="eqno">\n <eqn>{0}</eqn><span>({1})</span>\n </section>\n ' ,
234235 "tag" : "```math" ,
235236 },
236237 {
237238 "name" : "math_block" ,
238- "rex" : re .compile (r"^`{3}math\s+?([^`]+?)\s+?`{3}" , re .M ),
239+ "rex" : re .compile (r"^`{3}math\s+?([^`]+?)\s+?`{3}" , re .MULTILINE ),
239240 "tmpl" : "<section>\n <eqn>{0}</eqn>\n </section>\n " ,
240241 "tag" : "```math" ,
241242 },
@@ -270,14 +271,14 @@ def render(tex: str, displayMode: bool, macros: Any) -> str:
270271 {
271272 "name" : "math_block_eqno" ,
272273 "rex" : re .compile (
273- r"^`{3}math\s+?([^`]+?)\s+?`{3}\s*?\(([^)$\r\n]+?)\)" , re .M
274+ r"^`{3}math\s+?([^`]+?)\s+?`{3}\s*?\(([^)$\r\n]+?)\)" , re .MULTILINE
274275 ),
275276 "tmpl" : '<section class="eqno"><eqn>{0}</eqn><span>({1})</span></section>' ,
276277 "tag" : "```math" ,
277278 },
278279 {
279280 "name" : "math_block" ,
280- "rex" : re .compile (r"^`{3}math\s+?([^`]+?)\s+?`{3}" , re .M ),
281+ "rex" : re .compile (r"^`{3}math\s+?([^`]+?)\s+?`{3}" , re .MULTILINE ),
281282 "tmpl" : "<section><eqn>{0}</eqn></section>" ,
282283 "tag" : "```math" ,
283284 },
@@ -295,13 +296,15 @@ def render(tex: str, displayMode: bool, macros: Any) -> str:
295296 "block" : [
296297 {
297298 "name" : "math_block_eqno" ,
298- "rex" : re .compile (r"^\${2}([^$]*?)\${2}\s*?\(([^)$\r\n]+?)\)" , re .M ),
299+ "rex" : re .compile (
300+ r"^\${2}([^$]*?)\${2}\s*?\(([^)$\r\n]+?)\)" , re .MULTILINE
301+ ),
299302 "tmpl" : '<section class="eqno"><eqn>{0}</eqn><span>({1})</span></section>' ,
300303 "tag" : "$$" ,
301304 },
302305 {
303306 "name" : "math_block" ,
304- "rex" : re .compile (r"^\${2}([^$]*?)\${2}" , re .M ),
307+ "rex" : re .compile (r"^\${2}([^$]*?)\${2}" , re .MULTILINE ),
305308 "tmpl" : "<section><eqn>{0}</eqn></section>" ,
306309 "tag" : "$$" ,
307310 },
@@ -329,13 +332,15 @@ def render(tex: str, displayMode: bool, macros: Any) -> str:
329332 "block" : [
330333 {
331334 "name" : "math_block_eqno" ,
332- "rex" : re .compile (r"^\${2}([^$]*?)\${2}\s*?\(([^)$\r\n]+?)\)" , re .M ),
335+ "rex" : re .compile (
336+ r"^\${2}([^$]*?)\${2}\s*?\(([^)$\r\n]+?)\)" , re .MULTILINE
337+ ),
333338 "tmpl" : '<section class="eqno">\n <eqn>{0}</eqn><span>({1})</span>\n </section>\n ' ,
334339 "tag" : "$$" ,
335340 },
336341 {
337342 "name" : "math_block" ,
338- "rex" : re .compile (r"^\${2}([^$]*?)\${2}" , re .M ),
343+ "rex" : re .compile (r"^\${2}([^$]*?)\${2}" , re .MULTILINE ),
339344 "tmpl" : "<section>\n <eqn>{0}</eqn>\n </section>\n " ,
340345 "tag" : "$$" ,
341346 },
0 commit comments