Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mathics/builtin/box/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,8 +688,8 @@ def elements(self):
if self._elements is None:
# self.box_options
self._elements = elements_to_expressions(
self,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pyrefly is showing a number of type errors around this section of code. But that can be addressed some other time.

(
self,
self.base,
self.subindex,
self.superindex,
Expand Down
13 changes: 3 additions & 10 deletions mathics/format/box/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,12 @@ def eval_infix(
operator = [format_operator(op, form) for op in operator.elements]
return make_boxes_infix(elements, operator, py_precedence, grouping, form)
else:
encoding_rule = evaluation.definitions.get_ownvalue("$CharacterEncoding")
encoding = "UTF8" if encoding_rule is None else encoding_rule.value
op_str = (
operator.value if isinstance(operator, String) else operator.short_name
)
if encoding == "ASCII":
operator = format_operator(
String(operator_to_ascii.get(op_str, op_str)), form
)
else:
operator = format_operator(
String(operator_to_unicode.get(op_str, op_str)), form
)
operator = format_operator(
String(operator_to_unicode.get(op_str, op_str)), form
)

return make_boxes_infix(elements, operator, py_precedence, grouping, form)

Expand Down
22 changes: 16 additions & 6 deletions test/format/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ def test_makeboxes_text_fragile(str_expr, str_expected, form, msg):
format_result.to_text(evaluation=session.evaluation) == str_expected
), msg
else:
strresult = format_result.to_text(evaluation=session.evaluation)
strresult = format_result.to_text(
evaluation=session.evaluation, encoding="UTF-8"
)
assert strresult == str_expected


Expand Down Expand Up @@ -159,7 +161,9 @@ def test_makeboxes_tex_fragile(str_expr, str_expected, form, msg):
== str_expected.strip()
), msg
else:
strresult = format_result.to_tex(evaluation=session.evaluation)
strresult = format_result.to_tex(
evaluation=session.evaluation, encoding="UTF-8"
)
assert strresult.strip() == str_expected.strip()


Expand Down Expand Up @@ -196,10 +200,13 @@ def test_makeboxes_mathml_fragile(str_expr, str_expected, form, msg):
format_result = result.format(session.evaluation, form)
if msg:
assert (
format_result.to_mathml(evaluation=session.evaluation) == str_expected
format_result.to_mathml(evaluation=session.evaluation, encoding="UTF-8")
== str_expected
), msg
else:
strresult = format_result.to_mathml(evaluation=session.evaluation)
strresult = format_result.to_mathml(
evaluation=session.evaluation, encoding="UTF-8"
)
assert strresult == str_expected


Expand All @@ -212,10 +219,13 @@ def test_makeboxes_mathml(str_expr, str_expected, form, msg):
format_result = result.format(session.evaluation, form)
if msg:
assert (
format_result.to_mathml(evaluation=session.evaluation) == str_expected
format_result.to_mathml(evaluation=session.evaluation, encoding="UTF-8")
== str_expected
), msg
else:
strresult = format_result.to_mathml(evaluation=session.evaluation)
strresult = format_result.to_mathml(
evaluation=session.evaluation, encoding="UTF-8"
)
assert strresult == str_expected


Expand Down
Loading