Skip to content

Commit 9585f48

Browse files
committed
add wl-to-amslatex conversion table...
revise Differential symbol; allow two versions: \u1d451 | \uf74c
1 parent ef592eb commit 9585f48

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

mathics_scanner/characters.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
_wl_to_ascii = _data.get("wl-to-ascii-dict", {})
4444
_wl_to_ascii_re = re.compile(_data.get("wl-to-ascii-re", ""))
4545

46+
# AMS LaTeX replacements
47+
_wl_to_amstex = _data.get("wl-to-amstex", None)
48+
4649
# Conversion from WL to unicode
4750
_wl_to_unicode = _data.get("wl-to-unicode-dict", {})
4851
_wl_to_unicode_re = re.compile(_data.get("wl-to-unicode-re", ""))

mathics_scanner/generate/build_tables.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ def compile_tables(data: dict) -> dict:
9797
if "esc-alias" in v
9898
}
9999

100+
# WL to AMS LaTeX characters
101+
wl_to_amslatex = {
102+
v["wl-unicode"]: v.get("amslatex")
103+
for v in data.values()
104+
if "amslatex" in v and "wl-unicode" in v
105+
}
106+
100107
# operator-to-unicode dictionary entry
101108
operator_to_precedence = {
102109
v["operator-name"]: v["precedence"]
@@ -188,6 +195,7 @@ def compile_tables(data: dict) -> dict:
188195
"unicode-to-wl-re": unicode_to_wl_re,
189196
"wl-to-ascii-dict": wl_to_ascii_dict,
190197
"wl-to-ascii-re": wl_to_ascii_re,
198+
"wl-to-amslatex": wl_to_amslatex,
191199
"wl-to-unicode-dict": wl_to_unicode_dict,
192200
"wl-to-unicode-re": wl_to_unicode_re,
193201
}
@@ -207,6 +215,7 @@ def compile_tables(data: dict) -> dict:
207215
"unicode-to-operator",
208216
"unicode-to-wl-dict",
209217
"unicode-to-wl-re",
218+
"wl-to-amslatex",
210219
"wl-to-ascii-dict",
211220
"wl-to-ascii-re",
212221
"wl-to-unicode-dict",

mathics_scanner/tokeniser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
("ConjugateTranspose", r" \uf3c9 "),
149149
("HermitianConjugate", r" \uf3ce "),
150150
("Integral", r" \u222b "),
151-
("DifferentialD", r" \U0001D451 "),
151+
("DifferentialD", r" \u1d451 | \uf74c"),
152152
("Del", r" \u2207 "),
153153
# uf520 is Wolfram custom, 25ab is standard unicode
154154
("Square", r" \uf520 | \u25ab"),

test/test_tokeniser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ def test_int_repeated():
125125

126126

127127
def test_integeral():
128-
assert tokens("\u222B x \U0001D451 y") == [
128+
assert tokens("\u222B x \uf74c y") == [
129129
Token("Integral", "\u222B", 0),
130130
Token("Symbol", "x", 2),
131-
Token("DifferentialD", "\U0001D451", 4),
131+
Token("DifferentialD", "\uf74c", 4),
132132
Token("Symbol", "y", 6),
133133
]
134134

test/test_translation_regressions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def check_translation_regression(c: str, expected_translation: str):
1111

1212

1313
def test_translation_regressions():
14-
check_translation_regression("DifferentialD", "𝑑")
14+
check_translation_regression("DifferentialD", "\U0001D451")
1515
check_translation_regression("PartialD", "\u2202")
1616
check_translation_regression("Uranus", "\u2645")
1717
check_translation_regression("WeierstrassP", "\u2118")

0 commit comments

Comments
 (0)