Skip to content

Commit f41a7b9

Browse files
authored
Merge pull request #9 from Mathics3/use-replace_wl_with_unicode-from-core
Use replace_wl_with_unicode and replace_unicode_with_wl from mathics
2 parents b3bb5b0 + c9dd326 commit f41a7b9

File tree

3 files changed

+677
-156
lines changed

3 files changed

+677
-156
lines changed

mathicsscript/__main__.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111
from mathicsscript.termshell import (
1212
ShellEscapeException,
1313
TerminalShell,
14-
wl_replace_dict_esc,
15-
wl_replace_pattern,
1614
)
1715

1816
from mathicsscript.format import format_output
1917

18+
from mathics import replace_wl_with_unicode
2019
from mathics.core.parser import FileLineFeeder
2120
from mathics.core.definitions import Definitions
2221
from mathics.core.expression import Symbol, SymbolTrue, SymbolFalse
@@ -33,16 +32,6 @@
3332
from mathicsscript.version import __version__
3433

3534

36-
def replace_wl_to_unicode(wl_input: str) -> str:
37-
"""WL uses some non-unicode character for various things.
38-
Replace them with the unicode equivalent.
39-
Two known items are directed arrow and undirected arrow.
40-
"""
41-
return wl_replace_pattern.sub(
42-
lambda m: wl_replace_dict_esc[re.escape(m.group(0))], wl_input
43-
)
44-
45-
4635
def ensure_settings():
4736
home = Path.home()
4837
base_config_dir = home / ".config"
@@ -339,7 +328,7 @@ def main(
339328
current_pos = GNU_readline.get_current_history_length()
340329
for pos in range(last_pos, current_pos - 1):
341330
GNU_readline.remove_history_item(pos)
342-
wl_input = replace_wl_to_unicode(source_code.rstrip())
331+
wl_input = replace_wl_with_unicode(source_code.rstrip())
343332
GNU_readline.add_history(wl_input)
344333

345334
if query is None:

0 commit comments

Comments
 (0)