Skip to content

Commit 778e8ab

Browse files
committed
Remove $UseSansSerif. add autoload() ...
which can be called from front-ends.
1 parent 0d0036a commit 778e8ab

File tree

3 files changed

+4
-82
lines changed

3 files changed

+4
-82
lines changed

mathics/autoload/settings.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
Settings`$PreferredBackendMethod = "sympy"
1212
Unprotect[Settings`$PreferredBackendMethod]
1313

14+
(* FIXME: remove this when all front-ends are adjusted to set this. *)
1415
(* Some packages like Feyncalc, test for whether a they are being used
1516
inside a notbook. *)
1617
System`$Notebooks::usage = "Set True if the Mathics is being used with a notebook-based front end.";

mathics/builtin/inout.py

Lines changed: 1 addition & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
BoxConstruct,
1919
BoxConstructError,
2020
Operator,
21-
Predefined,
2221
)
2322
from mathics.builtin.tensors import get_dimensions
2423
from mathics.builtin.comparison import expr_min
@@ -51,35 +50,6 @@
5150
MULTI_NEWLINE_RE = re.compile(r"\n{2,}")
5251

5352

54-
class UseSansSerif(Predefined):
55-
"""
56-
<dl>
57-
<dt>'$UseSansSerif'
58-
<dd>controls whether the Web interfaces use a Sans-Serif font.
59-
</dl>
60-
61-
When set True, the output in MathMLForm uses SansSerif fonts instead
62-
of the standard fonts.
63-
64-
X> $UseSansSerif
65-
= True
66-
X> $UseSansSerif = False
67-
68-
"""
69-
70-
context = "System`"
71-
name = "$UseSansSerif"
72-
attributes = ("Unprotected",)
73-
value = True
74-
75-
rules = {"$UseSansSerif": str(value)}
76-
77-
messages = {}
78-
79-
def evaluate(self, evaluation):
80-
return Integer(self.value)
81-
82-
8353
class Format(Builtin):
8454
"""
8555
<dl>
@@ -2105,7 +2075,7 @@ def apply_mathml(self, expr, evaluation) -> Expression:
21052075

21062076
# mathml = '<math><mstyle displaystyle="true">%s</mstyle></math>' % xml
21072077
# #convert_box(boxes)
2108-
query = evaluation.parse("System`$UseSansSerif")
2078+
query = evaluation.parse("Settings`$UseSansSerif")
21092079
usesansserif = query.evaluate(evaluation).to_python()
21102080
if not is_a_picture:
21112081
if usesansserif:
@@ -2115,55 +2085,6 @@ def apply_mathml(self, expr, evaluation) -> Expression:
21152085
return Expression("RowBox", Expression(SymbolList, String(mathml)))
21162086

21172087

2118-
class HTMLForm(Builtin):
2119-
"""
2120-
<dl>
2121-
<dt>'HTMLForm[$expr$]'
2122-
<dd>displays $expr$ as a HTML expression.
2123-
</dl>
2124-
2125-
>> HTMLForm[HoldForm[Sqrt[a^3]]]
2126-
= ...
2127-
2128-
## Test cases for Unicode - redo please as a real test
2129-
>> MathMLForm[\\[Mu]]
2130-
= ...
2131-
2132-
# This can causes the TeX to fail
2133-
# >> MathMLForm[Graphics[Text["\u03bc"]]]
2134-
# = ...
2135-
2136-
## The <mo> should contain U+2062 INVISIBLE TIMES
2137-
## MathMLForm[MatrixForm[{{2*a, 0},{0,0}}]]
2138-
= ...
2139-
"""
2140-
2141-
def apply_hml(self, expr, evaluation) -> Expression:
2142-
"MakeBoxes[expr_, HTMLForm]"
2143-
2144-
boxes = MakeBoxes(expr).evaluate(evaluation)
2145-
try:
2146-
xml = boxes.boxes_to_mathml(evaluation=evaluation)
2147-
except BoxError:
2148-
evaluation.message(
2149-
"General",
2150-
"notboxes",
2151-
Expression("FullForm", boxes).evaluate(evaluation),
2152-
)
2153-
xml = ""
2154-
is_a_picture = xml[:6] == "<mtext"
2155-
2156-
# mathml = '<math><mstyle displaystyle="true">%s</mstyle></math>' % xml
2157-
# #convert_box(boxes)
2158-
query = evaluation.parse("System`$UseSansSerif")
2159-
usesansserif = query.evaluate(evaluation).to_python()
2160-
if not is_a_picture:
2161-
if usesansserif:
2162-
xml = '<mstyle mathvariant="sans-serif">%s</mstyle>' % xml
2163-
2164-
mathml = '<math display="block">%s</math>' % xml # convert_box(boxes)
2165-
return Expression("RowBox", Expression(SymbolList, String(mathml)))
2166-
21672088
class PythonForm(Builtin):
21682089
"""
21692090
<dl>

mathics/core/definitions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def valuesname(name) -> str:
4141
return name[7:-6].lower()
4242

4343

44-
def autoload_file(defs, root_dir_path: str, autoload_dir):
44+
def autoload_files(defs, root_dir_path: str, autoload_dir):
4545
from mathics.core.evaluation import Evaluation
4646

4747
# Load symbols from the autoload folder
@@ -109,7 +109,7 @@ def __init__(
109109
builtin_file = open(builtin_filename, "wb")
110110
pickle.dump(self.builtin, builtin_file, -1)
111111

112-
autoload_file(self, ROOT_DIR, "autoload")
112+
autoload_files(self, ROOT_DIR, "autoload")
113113
# Load symbols from the autoload folder
114114
for root, dirs, files in os.walk(os.path.join(ROOT_DIR, "autoload")):
115115
for path in [os.path.join(root, f) for f in files if f.endswith(".m")]:

0 commit comments

Comments
 (0)