add converting of tex-style script styles like \em
This commit is contained in:
parent
70439bfeb9
commit
e97995310d
@ -49,3 +49,7 @@ UTF8_REPLACEMENTS = {
|
||||
r'{\ss}': 'ß',
|
||||
r'{ß}': 'ß',
|
||||
}
|
||||
|
||||
TEX_SCRIPTSTYLES = {
|
||||
r'\em' : r'\emph'
|
||||
}
|
||||
|
@ -13,6 +13,27 @@ def migrate_old_utf8_escape(line:str):
|
||||
line = line[:m.start()] + new + line[m.end():]
|
||||
return line
|
||||
|
||||
def migrate_tex_script_styles(line: str):
|
||||
for old, new in TEX_SCRIPTSTYLES.items():
|
||||
while True:
|
||||
old = old.replace('\\', r'\\')
|
||||
m = re.search(r'{' + old + r' *(.*?)}', line)
|
||||
if m is None:
|
||||
break
|
||||
else:
|
||||
line = line[:m.start()] + new + '{' + m.groups()[0] + '}' + line[m.end():]
|
||||
return line
|
||||
|
||||
def migrate_old_quotes(line: str):
|
||||
while True:
|
||||
m = re.search(r',,(.*?)``', line)
|
||||
if m is None:
|
||||
break
|
||||
else:
|
||||
line = line[:m.start()] + r'\enquote{' + m.groups()[0] + r'}' + line[m.end():]
|
||||
print(line)
|
||||
return line
|
||||
|
||||
|
||||
def _migrate_lazy_math_alphabet(line: str, letters: str, short: str, alph: str):
|
||||
for letter in letters:
|
||||
@ -71,6 +92,8 @@ def optimize_line(line: str) -> str:
|
||||
line = migrate_deprecated(line)
|
||||
line = replace_unicode(line)
|
||||
line = migrate_old_utf8_escape(line)
|
||||
line = migrate_old_quotes(line)
|
||||
line = migrate_tex_script_styles(line)
|
||||
return line
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user