UTF8 replacements hinzugefügt
This commit is contained in:
parent
4e081919f5
commit
f4c5d4c4ae
2 changed files with 22 additions and 0 deletions
10
constants.py
10
constants.py
|
@ -38,3 +38,13 @@ UNICODE = {
|
||||||
'⇒': r'\implies',
|
'⇒': r'\implies',
|
||||||
'⇐': r'\impliedby'
|
'⇐': r'\impliedby'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UTF8_REPLACEMENTS = {
|
||||||
|
r'\"o': 'ö',
|
||||||
|
r'\"a': 'ä',
|
||||||
|
r'\"u': 'ü',
|
||||||
|
r'\"O': 'Ö',
|
||||||
|
r'\"A': 'Ä',
|
||||||
|
r'\"U': 'Ü',
|
||||||
|
r'\ss': 'ß',
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,17 @@ from constants import *
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
def migrate_old_utf8_escape(line:str):
|
||||||
|
for old, new in UTF8_REPLACEMENTS.items():
|
||||||
|
while True:
|
||||||
|
old = old.replace('\\', r'\\')
|
||||||
|
m = re.search(old, line)
|
||||||
|
if m is None:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
line = line[:m.start()] + new + line[m.end():]
|
||||||
|
return line
|
||||||
|
|
||||||
|
|
||||||
def _migrate_lazy_math_alphabet(line: str, letters: str, short: str, alph: str):
|
def _migrate_lazy_math_alphabet(line: str, letters: str, short: str, alph: str):
|
||||||
for letter in letters:
|
for letter in letters:
|
||||||
|
@ -59,6 +70,7 @@ def optimize_line(line: str) -> str:
|
||||||
line = migrate_lazy_math_alphabets(line)
|
line = migrate_lazy_math_alphabets(line)
|
||||||
line = migrate_deprecated(line)
|
line = migrate_deprecated(line)
|
||||||
line = replace_unicode(line)
|
line = replace_unicode(line)
|
||||||
|
line = migrate_old_utf8_escape(line)
|
||||||
return line
|
return line
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue