From f513083ee2ee0361b22df168a8137736b44854a1 Mon Sep 17 00:00:00 2001 From: mmatera Date: Fri, 30 Jan 2026 09:56:53 -0300 Subject: [PATCH 1/5] indentation --- mathics/format/box/outputforms.py | 2 +- mathics/format/render/mathml.py | 80 ++++++++++++++++++++++++------- 2 files changed, 63 insertions(+), 19 deletions(-) diff --git a/mathics/format/box/outputforms.py b/mathics/format/box/outputforms.py index 60d187f4d..415adba6e 100644 --- a/mathics/format/box/outputforms.py +++ b/mathics/format/box/outputforms.py @@ -30,7 +30,7 @@ def eval_mathmlform(expr: BaseElement, evaluation: Evaluation) -> BoxElementMixi boxes = format_element(expr, evaluation, SymbolTraditionalForm) try: - mathml = boxes.boxes_to_mathml(evaluation=evaluation) + mathml = boxes.boxes_to_mathml(evaluation=evaluation,_indent_level=1) except BoxError: evaluation.message( "General", diff --git a/mathics/format/render/mathml.py b/mathics/format/render/mathml.py index a9ecb2297..fa20b3a90 100644 --- a/mathics/format/render/mathml.py +++ b/mathics/format/render/mathml.py @@ -91,6 +91,7 @@ def encode_mathml(text: str) -> str: def string(self, **options) -> str: + text = self.value number_as_text = options.get("number_as_text", None) @@ -101,10 +102,15 @@ def string(self, **options) -> str: if number_as_text is None: number_as_text = SymbolFalse + + indent_level = options.get("_indent_level", 0) + indent_spaces = " "*indent_level + def render(format, string): encoded_text = encode_mathml(string) - return format % encoded_text + return indent_spaces + format % encoded_text + if text.startswith('"') and text.endswith('"'): text = text[1:-1] if not show_string_characters: @@ -171,6 +177,11 @@ def interpretation_box(self, **options): def pane_box(self, **options): + + indent_level = options.get("_indent_level", 0) + indent_spaces = " "*indent_level + options["_indent_level"] = indent_level + 1 + content = lookup_conversion_method(self.boxes, "mathml")(self.boxes, **options) options = self.box_options size = options.get("System`ImageSize", SymbolAutomatic).to_python() @@ -201,8 +212,8 @@ def pane_box(self, **options): dims += "overflow:hidden;" dims = f' style="{dims}" ' if dims: - return f"\n{content}\n" - return content + return f"{indent_level}\n{content}\n{indent_level}" + return f"{indent_level}{content}" add_conversion_fn(PaneBox, pane_box) @@ -212,7 +223,10 @@ def fractionbox(self, **options) -> str: _options = self.box_options.copy() _options.update(options) options = _options - return "\n%s\n%s\n" % ( + indent_level = options.get("_indent_level", 0) + indent_spaces = " "*indent_level + options["_indent_level"] = indent_level + 1 + return f"{indent_spaces}\n%s\n%s\n{indent_spaces}" % ( lookup_conversion_method(self.num, "mathml")(self.num, **options), lookup_conversion_method(self.den, "mathml")(self.den, **options), ) @@ -243,18 +257,22 @@ def boxes_to_mathml(box, **options): # invalid column alignment raise BoxConstructError joined_attrs = " ".join(f'{name}="{value}"' for name, value in attrs.items()) - result = f"\n" + indent_level = options.get("_indent_level", 0) + indent_spaces = " "*indent_level + result = f"{indent_spaces}\n" new_box_options = box_options.copy() new_box_options["inside_list"] = True + new_box_options["_indent_level"] = indent_level + 3 + for row in items: - result += "" + result += "{indent_spaces} \n" if isinstance(row, tuple): for item in row: - result += f"{boxes_to_mathml(item, **new_box_options)}" + result += f"\n{indent_spaces} {boxes_to_mathml(item, **new_box_options)}" else: - result += f"{boxes_to_mathml(row, **new_box_options)}" - result += "\n" - result += "" + result += f"\n{indent_spaces} \n{boxes_to_mathml(row, **new_box_options)}\n{indent_spaces} " + result += "{indent_spaces} \n" + result += "{indent_spaces}" # print(f"gridbox: {result}") return result @@ -266,13 +284,17 @@ def sqrtbox(self, **options): _options = self.box_options.copy() _options.update(options) options = _options + indent_level = options.get("_indent_level", 0) + indent_spaces = " "*indent_level + options["_indent_level"] = indent_level + 1 + if self.index: - return " %s %s " % ( + return f"{indent_spaces}\n%s\n%s\n{indent_spaces}" % ( lookup_conversion_method(self.radicand, "mathml")(self.radicand, **options), lookup_conversion_method(self.index, "mathml")(self.index, **options), ) - return "\n%s\n" % lookup_conversion_method(self.radicand, "mathml")( + return f"{indent_spaces}\n%s\n{indent_spaces}" % lookup_conversion_method(self.radicand, "mathml")( self.radicand, **options ) @@ -284,7 +306,10 @@ def subscriptbox(self, **options): _options = self.box_options.copy() _options.update(options) options = _options - return "\n%s\n%s\n" % ( + indent_level = options.get("_indent_level", 0) + indent_spaces = " "*indent_level + options["_indent_level"] = indent_level + 1 + return "{indent_spaces}\n%s\n%s\n{indent_spaces}" % ( lookup_conversion_method(self.base, "mathml")(self.base, **options), lookup_conversion_method(self.subindex, "mathml")(self.subindex, **options), ) @@ -297,7 +322,11 @@ def superscriptbox(self, **options): _options = self.box_options.copy() _options.update(options) options = _options - return "\n%s\n%s\n" % ( + indent_level = options.get("_indent_level", 0) + indent_spaces = " "*indent_level + options["_indent_level"] = indent_level + 1 + + return f"{indent_spaces}\n%s\n%s\n{indent_spaces}" % ( lookup_conversion_method(self.base, "mathml")(self.base, **options), lookup_conversion_method(self.superindex, "mathml")(self.superindex, **options), ) @@ -311,7 +340,12 @@ def subsuperscriptbox(self, **options): _options.update(options) options = _options options["inside_row"] = True - return "\n%s\n%s\n%s\n" % ( + + indent_level = options.get("_indent_level", 0) + indent_spaces = " "*indent_level + options["_indent_level"] = indent_level + 1 + + return f"{indent_spaces}\n%s\n%s\n%s\n{indent_spaces}" % ( lookup_conversion_method(self.base, "mathml")(self.base, **options), lookup_conversion_method(self.subindex, "mathml")(self.subindex, **options), lookup_conversion_method(self.superindex, "mathml")(self.superindex, **options), @@ -354,12 +388,15 @@ def is_list_interior(content): else: options["inside_row"] = True + indent_level = options.get("_indent_level", 0) + indent_spaces = " "*indent_level + options["_indent_level"] = indent_level + 1 + for element in self.items: result.append(lookup_conversion_method(element, "mathml")(element, **options)) - # print(f"mrow: {result}") - - return "\n%s\n" % "\n".join(result) + # print(f"mrow: {result}") + return f"{indent_spaces}\n{'\n'.join(result)}\n{indent_spaces}" add_conversion_fn(RowBox, rowbox) @@ -394,6 +431,10 @@ def graphicsbox(self, elements=None, **options) -> str: int(self.height), base64.b64encode(svg_body.encode("utf8")).decode("utf8"), ) + indent_level = options.get("_indent_level",0) + if indent_level: + mathml = " " * indent_level + mathml + # print("boxes_to_mathml", mathml) return mathml @@ -406,6 +447,9 @@ def graphics3dbox(self, elements=None, **options) -> str: json_repr = self.boxes_to_json(elements, **options) mathml = f'' mathml = f"\n\n\n{mathml}\n\n\n" + indent_level = options.get("_indent_level",0) + if indent_level: + mathml = " " * indent_level + mathml return mathml From d26de0d7f2e499150e7b5840962bf75159331f40 Mon Sep 17 00:00:00 2001 From: mmatera Date: Fri, 30 Jan 2026 09:59:51 -0300 Subject: [PATCH 2/5] mathml indent --- mathics/format/render/mathml.py | 49 ++++++++++++++++----------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/mathics/format/render/mathml.py b/mathics/format/render/mathml.py index fa20b3a90..7465465d0 100644 --- a/mathics/format/render/mathml.py +++ b/mathics/format/render/mathml.py @@ -102,15 +102,13 @@ def string(self, **options) -> str: if number_as_text is None: number_as_text = SymbolFalse - indent_level = options.get("_indent_level", 0) - indent_spaces = " "*indent_level - + indent_spaces = " " * indent_level + def render(format, string): encoded_text = encode_mathml(string) return indent_spaces + format % encoded_text - if text.startswith('"') and text.endswith('"'): text = text[1:-1] if not show_string_characters: @@ -179,9 +177,9 @@ def interpretation_box(self, **options): def pane_box(self, **options): indent_level = options.get("_indent_level", 0) - indent_spaces = " "*indent_level - options["_indent_level"] = indent_level + 1 - + indent_spaces = " " * indent_level + options["_indent_level"] = indent_level + 1 + content = lookup_conversion_method(self.boxes, "mathml")(self.boxes, **options) options = self.box_options size = options.get("System`ImageSize", SymbolAutomatic).to_python() @@ -224,7 +222,7 @@ def fractionbox(self, **options) -> str: _options.update(options) options = _options indent_level = options.get("_indent_level", 0) - indent_spaces = " "*indent_level + indent_spaces = " " * indent_level options["_indent_level"] = indent_level + 1 return f"{indent_spaces}\n%s\n%s\n{indent_spaces}" % ( lookup_conversion_method(self.num, "mathml")(self.num, **options), @@ -258,12 +256,12 @@ def boxes_to_mathml(box, **options): raise BoxConstructError joined_attrs = " ".join(f'{name}="{value}"' for name, value in attrs.items()) indent_level = options.get("_indent_level", 0) - indent_spaces = " "*indent_level + indent_spaces = " " * indent_level result = f"{indent_spaces}\n" new_box_options = box_options.copy() new_box_options["inside_list"] = True new_box_options["_indent_level"] = indent_level + 3 - + for row in items: result += "{indent_spaces} \n" if isinstance(row, tuple): @@ -285,17 +283,18 @@ def sqrtbox(self, **options): _options.update(options) options = _options indent_level = options.get("_indent_level", 0) - indent_spaces = " "*indent_level + indent_spaces = " " * indent_level options["_indent_level"] = indent_level + 1 - + if self.index: return f"{indent_spaces}\n%s\n%s\n{indent_spaces}" % ( lookup_conversion_method(self.radicand, "mathml")(self.radicand, **options), lookup_conversion_method(self.index, "mathml")(self.index, **options), ) - return f"{indent_spaces}\n%s\n{indent_spaces}" % lookup_conversion_method(self.radicand, "mathml")( - self.radicand, **options + return ( + f"{indent_spaces}\n%s\n{indent_spaces}" + % lookup_conversion_method(self.radicand, "mathml")(self.radicand, **options) ) @@ -307,8 +306,8 @@ def subscriptbox(self, **options): _options.update(options) options = _options indent_level = options.get("_indent_level", 0) - indent_spaces = " "*indent_level - options["_indent_level"] = indent_level + 1 + indent_spaces = " " * indent_level + options["_indent_level"] = indent_level + 1 return "{indent_spaces}\n%s\n%s\n{indent_spaces}" % ( lookup_conversion_method(self.base, "mathml")(self.base, **options), lookup_conversion_method(self.subindex, "mathml")(self.subindex, **options), @@ -323,9 +322,9 @@ def superscriptbox(self, **options): _options.update(options) options = _options indent_level = options.get("_indent_level", 0) - indent_spaces = " "*indent_level + indent_spaces = " " * indent_level options["_indent_level"] = indent_level + 1 - + return f"{indent_spaces}\n%s\n%s\n{indent_spaces}" % ( lookup_conversion_method(self.base, "mathml")(self.base, **options), lookup_conversion_method(self.superindex, "mathml")(self.superindex, **options), @@ -342,9 +341,9 @@ def subsuperscriptbox(self, **options): options["inside_row"] = True indent_level = options.get("_indent_level", 0) - indent_spaces = " "*indent_level + indent_spaces = " " * indent_level options["_indent_level"] = indent_level + 1 - + return f"{indent_spaces}\n%s\n%s\n%s\n{indent_spaces}" % ( lookup_conversion_method(self.base, "mathml")(self.base, **options), lookup_conversion_method(self.subindex, "mathml")(self.subindex, **options), @@ -389,13 +388,13 @@ def is_list_interior(content): options["inside_row"] = True indent_level = options.get("_indent_level", 0) - indent_spaces = " "*indent_level + indent_spaces = " " * indent_level options["_indent_level"] = indent_level + 1 for element in self.items: result.append(lookup_conversion_method(element, "mathml")(element, **options)) - # print(f"mrow: {result}") + # print(f"mrow: {result}") return f"{indent_spaces}\n{'\n'.join(result)}\n{indent_spaces}" @@ -431,10 +430,10 @@ def graphicsbox(self, elements=None, **options) -> str: int(self.height), base64.b64encode(svg_body.encode("utf8")).decode("utf8"), ) - indent_level = options.get("_indent_level",0) + indent_level = options.get("_indent_level", 0) if indent_level: mathml = " " * indent_level + mathml - + # print("boxes_to_mathml", mathml) return mathml @@ -447,7 +446,7 @@ def graphics3dbox(self, elements=None, **options) -> str: json_repr = self.boxes_to_json(elements, **options) mathml = f'' mathml = f"\n\n\n{mathml}\n\n\n" - indent_level = options.get("_indent_level",0) + indent_level = options.get("_indent_level", 0) if indent_level: mathml = " " * indent_level + mathml return mathml From cbceb63c8eb40d34e3cab236c938c71b965755c2 Mon Sep 17 00:00:00 2001 From: mmatera Date: Fri, 30 Jan 2026 13:56:31 -0300 Subject: [PATCH 3/5] update docs --- mathics/format/render/mathml.py | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/mathics/format/render/mathml.py b/mathics/format/render/mathml.py index 7465465d0..787d5086b 100644 --- a/mathics/format/render/mathml.py +++ b/mathics/format/render/mathml.py @@ -6,26 +6,25 @@ For readability, and following WMA MathML generated code, tags \ containing sub-tags are split on several lines, one by -sub element. For example, the Box expression +sub element, and indented according to the level of the part. \ +For example, the Box expression >> FractionBox[RowBox[{"a", "+", SuperscriptBox["b", "c"]}], "d"] produces ``` - -a -+ - -b -c - - -d + + a + + + + b + c + + + d ``` -In WMA, each line would be also indented adding one space on each \ -level of indentation. """ @@ -91,7 +90,6 @@ def encode_mathml(text: str) -> str: def string(self, **options) -> str: - text = self.value number_as_text = options.get("number_as_text", None) @@ -175,7 +173,6 @@ def interpretation_box(self, **options): def pane_box(self, **options): - indent_level = options.get("_indent_level", 0) indent_spaces = " " * indent_level options["_indent_level"] = indent_level + 1 @@ -210,8 +207,8 @@ def pane_box(self, **options): dims += "overflow:hidden;" dims = f' style="{dims}" ' if dims: - return f"{indent_level}\n{content}\n{indent_level}" - return f"{indent_level}{content}" + return f"{indent_spaces}\n{content}\n{indent_spaces}" + return f"{indent_spaces}{content}" add_conversion_fn(PaneBox, pane_box) @@ -308,7 +305,7 @@ def subscriptbox(self, **options): indent_level = options.get("_indent_level", 0) indent_spaces = " " * indent_level options["_indent_level"] = indent_level + 1 - return "{indent_spaces}\n%s\n%s\n{indent_spaces}" % ( + return f"{indent_spaces}\n%s\n%s\n{indent_spaces}" % ( lookup_conversion_method(self.base, "mathml")(self.base, **options), lookup_conversion_method(self.subindex, "mathml")(self.subindex, **options), ) @@ -395,7 +392,7 @@ def is_list_interior(content): result.append(lookup_conversion_method(element, "mathml")(element, **options)) # print(f"mrow: {result}") - return f"{indent_spaces}\n{'\n'.join(result)}\n{indent_spaces}" + return f"{indent_spaces}\n%s\n{indent_spaces}" % ("\n".join(result),) add_conversion_fn(RowBox, rowbox) From e556ec9c411e2e7f0c52b5fa4d54e1de156affc3 Mon Sep 17 00:00:00 2001 From: mmatera Date: Fri, 30 Jan 2026 15:46:19 -0300 Subject: [PATCH 4/5] update tests. adjust more indentation --- Makefile | 2 +- mathics/format/box/outputforms.py | 14 +++-- mathics/format/render/mathml.py | 9 +-- test/format/format_tests.yaml | 98 ++++++++++++------------------- test/test_session.py | 2 +- 5 files changed, 56 insertions(+), 69 deletions(-) diff --git a/Makefile b/Makefile index ffad84fd6..df51eae7c 100644 --- a/Makefile +++ b/Makefile @@ -137,7 +137,7 @@ plot-detailed-tests: #: Run pytest tests. Use environment variable "PYTEST_OPTIONS" for pytest options pytest: - MATHICS_CHARACTER_ENCODING="ASCII" $(PYTHON) -m pytest $(PYTEST_OPTIONS) $(PYTEST_WORKERS) test + MATHICS_CHARACTER_ENCODING="ASCII" $(PYTHON) -m pytest $(PYTEST_OPTIONS) $(PYTEST_WORKERS) #: Run pytest tests stopping at first failure. pytest-x : diff --git a/mathics/format/box/outputforms.py b/mathics/format/box/outputforms.py index 415adba6e..a248d127f 100644 --- a/mathics/format/box/outputforms.py +++ b/mathics/format/box/outputforms.py @@ -30,7 +30,7 @@ def eval_mathmlform(expr: BaseElement, evaluation: Evaluation) -> BoxElementMixi boxes = format_element(expr, evaluation, SymbolTraditionalForm) try: - mathml = boxes.boxes_to_mathml(evaluation=evaluation,_indent_level=1) + mathml = boxes.boxes_to_mathml(evaluation=evaluation, _indent_level=1) except BoxError: evaluation.message( "General", @@ -44,9 +44,15 @@ def eval_mathmlform(expr: BaseElement, evaluation: Evaluation) -> BoxElementMixi # #convert_box(boxes) query = evaluation.parse("Settings`$UseSansSerif") usesansserif = query.evaluate(evaluation).to_python() - if not is_a_picture: - if isinstance(usesansserif, bool) and usesansserif: - mathml = '%s' % mathml + if is_a_picture: + usesansserif = False + elif not isinstance(usesansserif, bool): + usesansserif = False + + if usesansserif: + mathml = '\n%s\n' % mathml + else: + mathml = "\n%s\n" % mathml mathml = '%s' % mathml # convert_box(boxes) return InterpretationBox( diff --git a/mathics/format/render/mathml.py b/mathics/format/render/mathml.py index 787d5086b..c3dc3f6a2 100644 --- a/mathics/format/render/mathml.py +++ b/mathics/format/render/mathml.py @@ -260,14 +260,15 @@ def boxes_to_mathml(box, **options): new_box_options["_indent_level"] = indent_level + 3 for row in items: - result += "{indent_spaces} \n" + result += f"{indent_spaces} " if isinstance(row, tuple): for item in row: - result += f"\n{indent_spaces} {boxes_to_mathml(item, **new_box_options)}" + new_box_options["_indent_level"] = indent_level + 4 + result += f"\n{indent_spaces} \n{boxes_to_mathml(item, **new_box_options)}\n{indent_spaces} " else: result += f"\n{indent_spaces} \n{boxes_to_mathml(row, **new_box_options)}\n{indent_spaces} " - result += "{indent_spaces} \n" - result += "{indent_spaces}" + result += f"\n{indent_spaces} \n" + result += f"{indent_spaces}" # print(f"gridbox: {result}") return result diff --git a/test/format/format_tests.yaml b/test/format/format_tests.yaml index 6254bbd02..b4bcd921d 100644 --- a/test/format/format_tests.yaml +++ b/test/format/format_tests.yaml @@ -139,8 +139,8 @@ mathml: System`InputForm: -4 System`OutputForm: -4 - System`StandardForm: "\n-\n4\n" - System`TraditionalForm: "\n-\n4\n" + System`StandardForm: "\n -\n 4\n" + System`TraditionalForm: "\n -\n 4\n" text: System`InputForm: '-4' System`OutputForm: '-4' @@ -158,8 +158,8 @@ mathml: System`InputForm: -4.32 System`OutputForm: -4.32 - System`StandardForm: "\n-\n4.32\n" - System`TraditionalForm: "\n-\n4.32\n" + System`StandardForm: "\n -\n 4.32\n" + System`TraditionalForm: "\n -\n 4.32\n" text: System`InputForm: '-4.32' System`OutputForm: '-4.32' @@ -177,8 +177,8 @@ mathml: System`InputForm: -4.33 System`OutputForm: -4.3 - System`StandardForm: "\n-\n4.33\n" - System`TraditionalForm: "\n-\n4.33\n" + System`StandardForm: "\n -\n 4.33\n" + System`TraditionalForm: "\n -\n 4.33\n" text: System`InputForm: -4.33`2. System`OutputForm: '-4.3' @@ -196,8 +196,8 @@ mathml: System`InputForm: -4.32 System`OutputForm: -4.320 - System`StandardForm: "\n-\n4.32\n" - System`TraditionalForm: "\n-\n4.32\n" + System`StandardForm: "\n -\n 4.32\n" + System`TraditionalForm: "\n -\n 4.32\n" text: System`InputForm: -4.32`4. System`OutputForm: '-4.320' @@ -271,10 +271,12 @@ System`OutputForm: - '1 / (1 + 1 / (1 + 1 / a))' - Fragile! - System`StandardForm: &id001 - - "\n1\n\n1\n+\n\n1\n\n1\n+\n\n1\na\n\n\n\n\n" + System`StandardForm: + - "\n 1\n \n 1\n +\n \n 1\n \n 1\n +\n \n 1\n a\n \n \n \n \n" + - Fragile! + System`TraditionalForm: + - "\n 1\n \n 1\n +\n \n 1\n \n 1\n +\n \n 1\n a\n \n \n \n \n" - Fragile! - System`TraditionalForm: *id001 text: System`InputForm: 1/(1 + 1/(1 + 1/a)) System`OutputForm: 1 / (1 + 1 / (1 + 1 / a)) @@ -292,8 +294,8 @@ mathml: System`InputForm: <|a -> x, b -> y, c -> <|d -> t|>|> System`OutputForm: '<|a -> x, b -> y, c -> <|d -> t|>|>' - System`StandardForm: "\n<|\n\n\na\n->\nx\n\n,\n\nb\n->\ny\n\n,\n\nc\n->\n\n<|\n\nd\n->\nt\n\n|>\n\n\n\n|>\n" - System`TraditionalForm: "\n<|\n\n\na\n->\nx\n\n,\n\nb\n->\ny\n\n,\n\nc\n->\n\n<|\n\nd\n->\nt\n\n|>\n\n\n\n|>\n" + System`StandardForm: "\n <|\n \n \n a\n ->\n x\n \n ,\n \n b\n ->\n y\n \n ,\n \n c\n ->\n \n <|\n \n d\n ->\n t\n \n |>\n \n \n \n |>\n" + System`TraditionalForm: "\n <|\n \n \n a\n ->\n x\n \n ,\n \n b\n ->\n y\n \n ,\n \n c\n ->\n \n <|\n \n d\n ->\n t\n \n |>\n \n \n \n |>\n" text: System`InputForm: <|a -> x, b -> y, c -> <|d -> t|>|> System`OutputForm: <|a -> x, b -> y, c -> <|d -> t|>|> @@ -311,8 +313,8 @@ Association[a -> x, b -> y, c -> Association[d -> t, Association[e -> u]]]: mathml: System`InputForm: "<|a -> x, b -> y, c -> <|d -> t, e -> u|>|>" System`OutputForm: '<|a -> x, b -> y, c -> <|d -> t, e -> u|>|>' - System`StandardForm: "\n<|\n\n\na\n->\nx\n\n,\n\nb\n->\ny\n\n,\n\nc\n->\n\n<|\n\n\nd\n->\nt\n\n,\n\ne\n->\nu\n\n\n|>\n\n\n\n|>\n" - System`TraditionalForm: "\n<|\n\n\na\n->\nx\n\n,\n\nb\n->\ny\n\n,\n\nc\n->\n\n<|\n\n\nd\n->\nt\n\n,\n\ne\n->\nu\n\n\n|>\n\n\n\n|>\n" + System`StandardForm: "\n <|\n \n \n a\n ->\n x\n \n ,\n \n b\n ->\n y\n \n ,\n \n c\n ->\n \n <|\n \n \n d\n ->\n t\n \n ,\n \n e\n ->\n u\n \n \n |>\n \n \n \n |>\n" + System`TraditionalForm: "\n <|\n \n \n a\n ->\n x\n \n ,\n \n b\n ->\n y\n \n ,\n \n c\n ->\n \n <|\n \n \n d\n ->\n t\n \n ,\n \n e\n ->\n u\n \n \n |>\n \n \n \n |>\n" text: System`InputForm: <|a -> x, b -> y, c -> <|d -> t, e -> u|>|> System`OutputForm: <|a -> x, b -> y, c -> <|d -> t, e -> u|>|> @@ -330,8 +332,8 @@ Complex[1.09*^12, 3.]: mathml: System`InputForm: 1.09*^12 + 3.*I System`OutputForm: '1.09×10^12 + 3. I' - System`StandardForm: "\n\n1.09\n*^\n12\n\n+\n\n3.\n \nI\n\n" - System`TraditionalForm: "\n\n1.09\n×\n\n10\n12\n\n\n+\n\n3.\n\nI\n\n" + System`StandardForm: "\n \n 1.09\n *^\n 12\n \n +\n \n 3.\n  \n I\n \n" + System`TraditionalForm: "\n \n 1.09\n ×\n \n 10\n 12\n \n \n +\n \n 3.\n \n I\n \n" text: System`InputForm: 1.09*^12 + 3.*I System`OutputForm: "1.09\xD710^12 + 3. I" @@ -458,18 +460,8 @@ Graphics[{}]: mathml: System`InputForm: "Grid[{{"Spanish", "Hola!"}, {"Portuguese", "Olà!"}, {"English", "Hi!"}}]" System`OutputForm: 'Spanish      Hola!Portuguese   Olà!English      Hi!' - System`StandardForm: "\nSpanishHola!\n\ - PortugueseOl\xE0!\nEnglishHi!\n\ - " - System`TraditionalForm: "\nSpanishHola!\n\ - PortugueseOl\xE0!\nEnglishHi!\n\ - " + System`StandardForm: "\n \n \n Spanish\n \n \n Hola!\n \n \n \n \n Portuguese\n \n \n Olà!\n \n \n \n \n English\n \n \n Hi!\n \n \n" + System`TraditionalForm: "\n \n \n Spanish\n \n \n Hola!\n \n \n \n \n Portuguese\n \n \n Olà!\n \n \n \n \n English\n \n \n Hi!\n \n \n" text: System`InputForm: "Grid[{{\"Spanish\", \"Hola!\"}, {\"Portuguese\", \"Ol\xE0!\"\ }, {\"English\", \"Hi!\"}}]" @@ -497,20 +489,8 @@ Grid[{{a,b},{c,d}}]: mathml: System`InputForm: Grid[{{a, b}, {c, d}}] System`OutputForm: 'a   bc   d' - System`StandardForm: ' - - ab - - cd - - ' - System`TraditionalForm: ' - - ab - - cd - - ' + System`StandardForm: "\n \n \n a\n \n \n b\n \n \n \n \n c\n \n \n d\n \n \n" + System`TraditionalForm: "\n \n \n a\n \n \n b\n \n \n \n \n c\n \n \n d\n \n \n" text: System`InputForm: Grid[{{a, b}, {c, d}}] System`OutputForm: 'a b @@ -543,8 +523,8 @@ Integrate[F[x], {x, a, g[b]}]: mathml: System`InputForm: 'Integrate[F[x], {x, a, g[b]}]' System`OutputForm: 'Integrate[F[x], {x, a, g[b]}]' - System`StandardForm: "\n\n\na\n\ng\n[\nb\n]\n\n\n\n\nF\n[\nx\n]\n\n\n\n𝑑\nx\n\n" - System`TraditionalForm: "\n\n\na\n\ng\n(\nb\n)\n\n\n\n\nF\n(\nx\n)\n\n\n\n𝑑\nx\n\n" + System`StandardForm: "\n \n \n a\n \n g\n [\n b\n ]\n \n \n \u2062\n \n F\n [\n x\n ]\n \n \u2062\n \n 𝑑\n x\n \n" + System`TraditionalForm: "\n \n \n a\n \n g\n (\n b\n )\n \n \n \u2062\n \n F\n (\n x\n )\n \n \u2062\n \n 𝑑\n x\n \n" text: System`InputForm: Integrate[F[x], {x, a, g[b]}] System`OutputForm: Integrate[F[x], {x, a, g[b]}] @@ -568,8 +548,8 @@ MatrixForm[{{a,b},{c,d}}]: mathml: System`InputForm: MatrixForm[{{a, b}, {c, d}}] System`OutputForm: 'a   bc   d' - System`StandardForm: "\n(\n\nab\ncd\n\n)\n" - System`TraditionalForm: "\n(\n\nab\ncd\n\n)\n" + System`StandardForm: "\n (\n\n \n \n a\n \n \n b\n \n \n \n \n c\n \n \n d\n \n \n\n )\n" + System`TraditionalForm: "\n (\n\n \n \n a\n \n \n b\n \n \n \n \n c\n \n \n d\n \n \n\n )\n" text: System`InputForm: MatrixForm[{{a, b}, {c, d}}] System`OutputForm: 'a b @@ -607,10 +587,10 @@ Sqrt[1/(1+1/(1+1/a))]: - 'Sqrt[1 / (1 + 1 / (1 + 1 / a))]' - Fragile! System`StandardForm: - - "\n\n1\n\n1\n+\n\n1\n\n1\n+\n\n1\na\n\n\n\n\n\n" + - "\n \n 1\n \n 1\n +\n \n 1\n \n 1\n +\n \n 1\n a\n \n \n \n \n \n" - Fragile! System`TraditionalForm: - - "\n\n1\n\n1\n+\n\n1\n\n1\n+\n\n1\na\n\n\n\n\n\n" + - "\n \n 1\n \n 1\n +\n \n 1\n \n 1\n +\n \n 1\n a\n \n \n \n \n \n" - Fragile! text: System`InputForm: Sqrt[1/(1 + 1/(1 + 1/a))] @@ -633,8 +613,8 @@ Subscript[a, 4]: System`OutputForm: - 'Subscript[a, 4]' - Fragile! - System`StandardForm: "\na\n4\n" - System`TraditionalForm: "\na\n4\n" + System`StandardForm: "\n a\n 4\n" + System`TraditionalForm: "\n a\n 4\n" text: System`InputForm: Subscript[a, 4] System`OutputForm: Subscript[a, 4] @@ -654,8 +634,8 @@ Subsuperscript[a, p, q]: mathml: System`InputForm: Subsuperscript[a, p, q] System`OutputForm: 'Subsuperscript[a, p, q]' - System`StandardForm: "\na\np\nq\n" - System`TraditionalForm: "\na\np\nq\n" + System`StandardForm: "\n a\n p\n q\n" + System`TraditionalForm: "\n a\n p\n q\n" text: System`InputForm: Subsuperscript[a, p, q] System`OutputForm: Subsuperscript[a, p, q] @@ -716,8 +696,8 @@ TableForm[{{a,b},{c,d}}]: mathml: System`InputForm: TableForm[{{a, b}, {c, d}}] System`OutputForm: 'a   bc   d' - System`StandardForm: "\nab\ncd\n" - System`TraditionalForm: "\nab\ncd\n" + System`StandardForm: "\n \n \n a\n \n \n b\n \n \n \n \n c\n \n \n d\n \n \n" + System`TraditionalForm: "\n \n \n a\n \n \n b\n \n \n \n \n c\n \n \n d\n \n \n" text: System`InputForm: TableForm[{{a, b}, {c, d}}] System`OutputForm: 'a b @@ -807,7 +787,7 @@ a^(g[b]/c): mathml: System`InputForm: a^(g[b]/c) System`OutputForm: 'a ^ (g[b] / c)' - System`TraditionalForm: "\na\n\n\ng\n(\nb\n)\n\nc\n\n" + System`TraditionalForm: "\n a\n \n \n g\n (\n b\n )\n \n c\n \n" text: System`InputForm: a^(g[b]/c) System`OutputForm: a ^ (g[b] / c) @@ -825,8 +805,8 @@ a^4: mathml: System`InputForm: 'a^4' System`OutputForm: 'a ^ 4' - System`StandardForm: "\na\n4\n" - System`TraditionalForm: "\na\n4\n" + System`StandardForm: "\n a\n 4\n" + System`TraditionalForm: "\n a\n 4\n" text: System`InputForm: a^4 System`OutputForm: a ^ 4 @@ -870,7 +850,7 @@ a+PrecedenceForm[b+c,10]: System`StandardForm: 'a+\left(b+c\right)' mathml: System`OutputForm: 'a + (b + c)' - System`StandardForm: "\na\n+\n\n(\n\nb\n+\nc\n\n)\n\n" + System`StandardForm: "\n a\n +\n \n (\n \n b\n +\n c\n \n )\n \n" text: System`InputForm: 'a + (PrecedenceForm[b + c, 10])' System`OutputForm: 'a + (b + c)' diff --git a/test/test_session.py b/test/test_session.py index 4f04fb0df..08d779a1f 100644 --- a/test/test_session.py +++ b/test/test_session.py @@ -55,7 +55,7 @@ def test_session_format_evaluation(): assert session.format_result(form="text") == "a / b" assert session.format_result(form="latex") == "\\frac{a}{b}" assert session.format_result(form="xml") == ( - '\na\nb\n' + '\n \n a\n b\n \n' ) From 2951a175963168feadb61a977af190dbe78c9deb Mon Sep 17 00:00:00 2001 From: Juan Mauricio Matera Date: Fri, 30 Jan 2026 18:02:55 -0300 Subject: [PATCH 5/5] restore Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index df51eae7c..ffad84fd6 100644 --- a/Makefile +++ b/Makefile @@ -137,7 +137,7 @@ plot-detailed-tests: #: Run pytest tests. Use environment variable "PYTEST_OPTIONS" for pytest options pytest: - MATHICS_CHARACTER_ENCODING="ASCII" $(PYTHON) -m pytest $(PYTEST_OPTIONS) $(PYTEST_WORKERS) + MATHICS_CHARACTER_ENCODING="ASCII" $(PYTHON) -m pytest $(PYTEST_OPTIONS) $(PYTEST_WORKERS) test #: Run pytest tests stopping at first failure. pytest-x :