fix bad regexes
This commit is contained in:
parent
7a7e199f91
commit
f54b569e26
1 changed files with 8 additions and 6 deletions
|
@ -1,13 +1,14 @@
|
||||||
from constants import ENVIRONMENTS, ALPHABETS, DEPRECATED
|
from constants import ENVIRONMENTS, ALPHABETS, DEPRECATED
|
||||||
import re
|
import re
|
||||||
import pathlib
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
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:
|
||||||
while True:
|
while True:
|
||||||
m = re.search(r'\\%s%s(?=![a-zA-Z@])' % (short, letter), line)
|
if r'\fS' in line:
|
||||||
|
pass
|
||||||
|
m = re.search(r'\\%s%s(?![a-zA-Z@])' % (short, letter), line)
|
||||||
if m is None:
|
if m is None:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
@ -16,7 +17,7 @@ def _migrate_lazy_math_alphabet(line: str, letters: str, short: str, alph: str):
|
||||||
|
|
||||||
|
|
||||||
def migrate_lazy_math_alphabets(line: str) -> str:
|
def migrate_lazy_math_alphabets(line: str) -> str:
|
||||||
for short, alph in ALPHABETS:
|
for short, alph in ALPHABETS.items():
|
||||||
if short == '':
|
if short == '':
|
||||||
line = _migrate_lazy_math_alphabet(line, 'NZQRCFK', '', alph)
|
line = _migrate_lazy_math_alphabet(line, 'NZQRCFK', '', alph)
|
||||||
else:
|
else:
|
||||||
|
@ -30,7 +31,7 @@ def migrate_deprecated(line: str) -> str:
|
||||||
for old, new in DEPRECATED.items():
|
for old, new in DEPRECATED.items():
|
||||||
while True:
|
while True:
|
||||||
old = old.replace('\\', r'\\')
|
old = old.replace('\\', r'\\')
|
||||||
m = re.search(old + '(?=![a-zA-Z@])', line)
|
m = re.search(old + '(?![a-zA-Z@])', line)
|
||||||
if m is None:
|
if m is None:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
@ -64,6 +65,7 @@ def convert(path: Path):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
here = Path('.')
|
here = Path('.').resolve()
|
||||||
for file in here.rglob('*.tex'):
|
files = here.rglob('*.tex')
|
||||||
|
for file in files:
|
||||||
convert(Path(file))
|
convert(Path(file))
|
||||||
|
|
Loading…
Reference in a new issue