From 5a627ee1f9501f8f7bd5e4d2d57156b016a575f0 Mon Sep 17 00:00:00 2001 From: cuppajoeman Date: Mon, 14 Oct 2024 00:08:46 -0400 Subject: [PATCH] feat: make sure that subsup responds to display mode --- latex2mathml/converter.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/latex2mathml/converter.py b/latex2mathml/converter.py index 659e8b1..2e42dff 100644 --- a/latex2mathml/converter.py +++ b/latex2mathml/converter.py @@ -55,6 +55,7 @@ r"\varsupsetneqq", ) MATH_MODE_PATTERN = re.compile(r"\\\$|\$|\\?[^\\$]+") +display_mode = "" class Mode(enum.Enum): @@ -68,6 +69,8 @@ def convert( display: str = "inline", parent: Optional[Element] = None, ) -> str: + global display_mode + display_mode = display math = convert_to_element(latex, xmlns, display, parent) return _convert(math) @@ -276,7 +279,9 @@ def _convert_command(node: Node, parent: Element, font: Optional[Dict[str, Optio if column_lines: attributes["columnlines"] = column_lines - if command == commands.SUBSUP and node.children is not None and node.children[0].token == commands.GCD: + if display_mode == "block" and command == commands.SUBSUP: + tag = "munderover" + elif command == commands.SUBSUP and node.children is not None and node.children[0].token == commands.GCD: tag = "munderover" elif command == commands.SUPERSCRIPT and modifier in (commands.LIMITS, commands.OVERBRACE): tag = "mover"