Skip to content

Commit 3bf1275

Browse files
authored
Use defined System Symbols (#204)
1 parent 6097500 commit 3bf1275

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

mathics_django/web/format.py

+10-11
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
SymbolFullForm,
1717
SymbolGraphics,
1818
SymbolGraphics3D,
19+
SymbolInputForm,
1920
SymbolMathMLForm,
2021
SymbolOutputForm,
2122
SymbolStandardForm,
@@ -84,31 +85,31 @@ def eval_boxes(result, fn: Callable, obj, **options):
8485
result = expr.elements[0].format(obj, expr_type)
8586
return result.boxes_to_text()
8687
elif expr_head is SymbolGraphics:
87-
result = Expression(SymbolStandardForm, expr).format(obj, "System`MathMLForm")
88+
result = Expression(SymbolStandardForm, expr).format(obj, SymbolMathMLForm)
8889

8990
# This part was derived from and the same as evaluation.py format_output.
9091

9192
use_quotes = get_settings_value(obj.definitions, "Settings`$QuotedStrings")
9293

9394
if format == "text":
94-
result = expr.format(obj, "System`OutputForm")
95+
result = expr.format(obj, SymbolOutputForm)
9596
result = eval_boxes(result, result.boxes_to_text, obj)
9697

9798
if use_quotes:
9899
result = '"' + result + '"'
99100

100101
return result
101102
elif format == "xml":
102-
result = Expression(SymbolStandardForm, expr).format(obj, "System`MathMLForm")
103+
result = Expression(SymbolStandardForm, expr).format(obj, SymbolMathMLForm)
103104
elif format == "tex":
104-
result = Expression(SymbolStandardForm, expr).format(obj, "System`TeXForm")
105+
result = Expression(SymbolStandardForm, expr).format(obj, SymbolTeXForm)
105106
elif format == "unformatted":
106107
if expr_head is PyMathicsGraph and hasattr(expr, "G"):
107108
return format_graph(expr.G)
108109
if expr_head is SymbolCompiledFunction:
109-
result = expr.format(obj, "System`OutputForm")
110+
result = expr.format(obj, SymbolOutputForm)
110111
elif expr_head is SymbolString:
111-
result = expr.format(obj, "System`InputForm")
112+
result = expr.format(obj, SymbolInputForm)
112113
result = result.boxes_to_text()
113114

114115
if not use_quotes:
@@ -118,16 +119,14 @@ def eval_boxes(result, fn: Callable, obj, **options):
118119
return result
119120
elif expr_head is SymbolGraphics3D:
120121
form_expr = Expression(SymbolStandardForm, expr)
121-
result = form_expr.format(obj, "System`StandardForm")
122+
result = form_expr.format(obj, SymbolStandardForm)
122123
return eval_boxes(result, result.boxes_to_js, obj)
123124
elif expr_head is SymbolGraphics:
124125
form_expr = Expression(SymbolStandardForm, expr)
125-
result = form_expr.format(obj, "System`StandardForm")
126+
result = form_expr.format(obj, SymbolStandardForm)
126127
return eval_boxes(result, result.boxes_to_svg, obj)
127128
else:
128-
result = Expression(SymbolStandardForm, expr).format(
129-
obj, "System`MathMLForm"
130-
)
129+
result = Expression(SymbolStandardForm, expr).format(obj, SymbolMathMLForm)
131130
else:
132131
raise ValueError
133132

0 commit comments

Comments
 (0)