|
16 | 16 | from math import ceil |
17 | 17 | from typing import Optional |
18 | 18 |
|
19 | | -from mathics.builtin.box.layout import GridBox, RowBox, to_boxes |
| 19 | +from mathics.builtin.box.layout import ( |
| 20 | + GridBox, |
| 21 | + InterpretationBox, |
| 22 | + PaneBox, |
| 23 | + RowBox, |
| 24 | + to_boxes, |
| 25 | +) |
20 | 26 | from mathics.builtin.forms.base import FormBaseClass |
21 | 27 | from mathics.builtin.makeboxes import MakeBoxes, NumberForm_to_String |
22 | 28 | from mathics.builtin.tensors import get_dimensions |
|
54 | 60 | SymbolOutputForm, |
55 | 61 | SymbolRowBox, |
56 | 62 | SymbolRuleDelayed, |
| 63 | + SymbolStandardForm, |
57 | 64 | SymbolSubscriptBox, |
58 | 65 | SymbolSuperscriptBox, |
59 | 66 | ) |
60 | 67 | from mathics.eval.makeboxes import StringLParen, StringRParen, format_element |
61 | 68 | from mathics.eval.testing_expressions import expr_min |
| 69 | +from mathics.format.outputform import expression_to_outputform_text |
62 | 70 |
|
63 | 71 | MULTI_NEWLINE_RE = re.compile(r"\n{2,}") |
64 | 72 |
|
@@ -561,8 +569,18 @@ class OutputForm(FormBaseClass): |
561 | 569 | = -Graphics- |
562 | 570 | """ |
563 | 571 |
|
| 572 | + formats = {"OutputForm[s_String]": "s"} |
564 | 573 | summary_text = "plain-text output format" |
565 | 574 |
|
| 575 | + def eval_makeboxes(self, expr, form, evaluation): |
| 576 | + """MakeBoxes[OutputForm[expr_], form_]""" |
| 577 | + print(" eval Makeboxes outputform") |
| 578 | + text_outputform = str(expression_to_outputform_text(expr, evaluation, form)) |
| 579 | + elem1 = PaneBox(String(text_outputform)) |
| 580 | + elem2 = Expression(SymbolOutputForm, expr) |
| 581 | + result = InterpretationBox(elem1, elem2) |
| 582 | + return result |
| 583 | + |
566 | 584 |
|
567 | 585 | class PythonForm(FormBaseClass): |
568 | 586 | """ |
@@ -707,7 +725,7 @@ class TeXForm(FormBaseClass): |
707 | 725 |
|
708 | 726 | def eval_tex(self, expr, evaluation) -> Expression: |
709 | 727 | "MakeBoxes[expr_, TeXForm]" |
710 | | - boxes = MakeBoxes(expr).evaluate(evaluation) |
| 728 | + boxes = format_element(expr, evaluation, SymbolStandardForm) |
711 | 729 | try: |
712 | 730 | # Here we set ``show_string_characters`` to False, to reproduce |
713 | 731 | # the standard behaviour in WMA. Remove this parameter to recover the |
|
0 commit comments