Skip to content

Commit 8b994d3

Browse files
authored
Merge pull request #51 from Mathics3/amstext+WL-unicode-convert
Amstext+wl unicode convert
2 parents ef592eb + 8c62b5e commit 8b994d3

11 files changed

+1053
-53
lines changed

mathics_scanner/characters.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@
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
47-
_wl_to_unicode = _data.get("wl-to-unicode-dict", {})
50+
_wl_to_unicode = _data.get("wl-to-unicode-dict", _data.get("wl_to_ascii"))
4851
_wl_to_unicode_re = re.compile(_data.get("wl-to-unicode-re", ""))
4952

5053
# Conversion from unicode to WL
@@ -58,6 +61,7 @@
5861
aliased_characters = _data.get("aliased-characters", {})
5962

6063

64+
# Deprecated
6165
def replace_wl_with_plain_text(wl_input: str, use_unicode=True) -> str:
6266
"""
6367
The Wolfram Language uses specific Unicode characters to represent Wolfram
@@ -78,9 +82,12 @@ def replace_wl_with_plain_text(wl_input: str, use_unicode=True) -> str:
7882
r = _wl_to_unicode_re if use_unicode else _wl_to_ascii_re
7983
d = _wl_to_unicode if use_unicode else _wl_to_ascii
8084

81-
return r.sub(lambda m: d[m.group(0)], wl_input)
85+
# The below on when use_unicode is False will sometime test on "ascii" twice.
86+
# But this routine should be deprecated.
87+
return r.sub(lambda m: d.get(m.group(0), _wl_to_ascii.get(m.group(0))), wl_input)
8288

8389

90+
# Deprecated
8491
def replace_unicode_with_wl(unicode_input: str) -> str:
8592
"""
8693
The Wolfram Language uses specific Unicode characters to represent Wolfram

0 commit comments

Comments
 (0)