diff --git a/mathics/builtin/logic.py b/mathics/builtin/logic.py index c854e97bcf..3bd85e3f8f 100644 --- a/mathics/builtin/logic.py +++ b/mathics/builtin/logic.py @@ -137,7 +137,7 @@ class Implies(BinaryOperator): If an expression does not evaluate to 'True' or 'False', 'Implies' returns a result in symbolic form: >> Implies[a, Implies[b, Implies[True, c]]] - = a \uF523 b \uF523 c + = a ⟹ b ⟹ c """ operator = "\uF523" @@ -171,7 +171,7 @@ class Equivalent(BinaryOperator): If all expressions do not evaluate to 'True' or 'False', 'Equivalent' returns a result in symbolic form: >> Equivalent[a, b, c] - = a \u29E6 b \u29E6 c + = a ⇔ b ⇔ c Otherwise, 'Equivalent' returns a result in DNF >> Equivalent[a, b, True, c] = a && b && c diff --git a/mathics/core/evaluation.py b/mathics/core/evaluation.py index c8f3ceaa34..2b9d7cb540 100644 --- a/mathics/core/evaluation.py +++ b/mathics/core/evaluation.py @@ -228,7 +228,12 @@ def display(self, data, metadata): class Evaluation(object): def __init__( - self, definitions=None, output=None, format="text", catch_interrupt=True + self, + definitions=None, + output=None, + format="text", + catch_interrupt=True, + use_unicode=True ) -> None: from mathics.core.definitions import Definitions from mathics.core.expression import Symbol @@ -242,6 +247,7 @@ def __init__( self.stopped = False self.out = [] self.output = output if output else Output() + self.use_unicode = use_unicode self.listeners = {} self.options = None self.predetermined_out = None diff --git a/mathics/core/expression.py b/mathics/core/expression.py index 3dfacdfd19..b8bddce72f 100644 --- a/mathics/core/expression.py +++ b/mathics/core/expression.py @@ -10,6 +10,7 @@ from typing import Any from itertools import chain from bisect import bisect_left +from mathics_scanner.characters import replace_wl_with_plain_text from functools import lru_cache @@ -1906,7 +1907,16 @@ def do_copy(self) -> "Symbol": return Symbol(self.name) def boxes_to_text(self, **options) -> str: - return str(self.name) + name = str(self.name) + + if "evaluation" in options: + e = options["evaluation"] + return replace_wl_with_plain_text(name, use_unicode=e.use_unicode) + else: + return name + + def boxes_to_xml(self, **options) -> str: + return replace_wl_with_plain_text(str(self.name)) def atom_to_boxes(self, f, evaluation) -> "String": return String(evaluation.definitions.shorten_name(self.name)) @@ -2725,6 +2735,10 @@ def boxes_to_text(self, show_string_characters=False, **options) -> str: ): value = value[1:-1] + if "evaluation" in options: + e = options["evaluation"] + value = replace_wl_with_plain_text(value, e.use_unicode) + return value def boxes_to_xml(self, show_string_characters=False, **options) -> str: @@ -2742,7 +2756,7 @@ def boxes_to_xml(self, show_string_characters=False, **options) -> str: text = self.value def render(format, string): - encoded_text = encode_mathml(string) + encoded_text = encode_mathml(replace_wl_with_plain_text(string)) return format % encoded_text if text.startswith('"') and text.endswith('"'):