add support for replacing unicode
This commit is contained in:
parent
f54b569e26
commit
6929d13dcd
2 changed files with 21 additions and 1 deletions
11
constants.py
11
constants.py
|
@ -20,3 +20,14 @@ DEPRECATED = {
|
||||||
r'\sm': r'\setminus',
|
r'\sm': r'\setminus',
|
||||||
r'\st': r'^{\ast}',
|
r'\st': r'^{\ast}',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UNICODE = {
|
||||||
|
'∃': r'\exists',
|
||||||
|
'∀': r'\forall',
|
||||||
|
'ℕ': r'\mathbb{N}',
|
||||||
|
'ℤ': r'\mathbb{Z}',
|
||||||
|
'Λ': r'\Lambda',
|
||||||
|
'⇔': r'\iff',
|
||||||
|
'⇒': r'\implies',
|
||||||
|
'⇐': r'\impliedby'
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from constants import ENVIRONMENTS, ALPHABETS, DEPRECATED
|
from constants import *
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
@ -28,6 +28,8 @@ def migrate_lazy_math_alphabets(line: str) -> str:
|
||||||
|
|
||||||
|
|
||||||
def migrate_deprecated(line: str) -> str:
|
def migrate_deprecated(line: str) -> str:
|
||||||
|
if '∃' in line:
|
||||||
|
foo = 2
|
||||||
for old, new in DEPRECATED.items():
|
for old, new in DEPRECATED.items():
|
||||||
while True:
|
while True:
|
||||||
old = old.replace('\\', r'\\')
|
old = old.replace('\\', r'\\')
|
||||||
|
@ -39,6 +41,12 @@ def migrate_deprecated(line: str) -> str:
|
||||||
return line
|
return line
|
||||||
|
|
||||||
|
|
||||||
|
def replace_unicode(line: str) -> str:
|
||||||
|
for old, new in UNICODE.items():
|
||||||
|
line = line.replace(old, r'\ensuremath{%s}' % new)
|
||||||
|
return line
|
||||||
|
|
||||||
|
|
||||||
def migrate_environments(line: str) -> str:
|
def migrate_environments(line: str) -> str:
|
||||||
for old_env, new_env in ENVIRONMENTS.items():
|
for old_env, new_env in ENVIRONMENTS.items():
|
||||||
line = line.replace(r'\begin{%s}' % old_env, r'\begin{%s}' % new_env)
|
line = line.replace(r'\begin{%s}' % old_env, r'\begin{%s}' % new_env)
|
||||||
|
@ -50,6 +58,7 @@ def optimize_line(line: str) -> str:
|
||||||
line = migrate_environments(line)
|
line = migrate_environments(line)
|
||||||
line = migrate_lazy_math_alphabets(line)
|
line = migrate_lazy_math_alphabets(line)
|
||||||
line = migrate_deprecated(line)
|
line = migrate_deprecated(line)
|
||||||
|
line = replace_unicode(line)
|
||||||
return line
|
return line
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue