2020-11-23 01:15:19 +01:00
|
|
|
import sys
|
|
|
|
import re
|
|
|
|
|
2020-11-24 19:31:28 +01:00
|
|
|
for filename in sys.argv[1:]:
|
|
|
|
with open(filename, 'r') as infile:
|
|
|
|
content = infile.read()
|
2020-11-23 01:15:19 +01:00
|
|
|
|
2020-11-24 19:31:28 +01:00
|
|
|
# Replace _string_ with html
|
2020-12-07 22:02:36 +01:00
|
|
|
html_span_head = '<span>'
|
|
|
|
html_input_head = '<input type="text" data-expected="'
|
|
|
|
html_input_tail = '"/>'
|
|
|
|
html_span_tail = '</span>'
|
2021-01-06 01:54:53 +01:00
|
|
|
content = re.sub(r'(\s|\"|)([a-zA-Z\-\ÿ]+|)_([āēīōūa-zA-Z\-]+)_(\.|\,|)', r'\1' + html_span_head + r'\2' + html_input_head + r'\3' + html_input_tail + r'\4' + html_span_tail, content)
|
2020-11-23 01:15:19 +01:00
|
|
|
|
2020-11-24 19:31:28 +01:00
|
|
|
# Replace vowel-dash-vowel with vowels with macrons
|
|
|
|
content = content.replace('A-A', 'Ā')
|
|
|
|
content = content.replace('a-a', 'ā')
|
|
|
|
content = content.replace('E-E', 'Ē')
|
|
|
|
content = content.replace('e-e', 'ē')
|
|
|
|
content = content.replace('I-I', 'Ī')
|
|
|
|
content = content.replace('i-i', 'ī')
|
|
|
|
content = content.replace('O-O', 'Ō')
|
|
|
|
content = content.replace('o-o', 'ō')
|
|
|
|
content = content.replace('U-U', 'Ū')
|
|
|
|
content = content.replace('u-u', 'ū')
|
2020-11-23 01:15:19 +01:00
|
|
|
|
2020-12-03 20:22:58 +01:00
|
|
|
with open(filename + '.html', 'w') as outfile:
|
2020-11-24 19:31:28 +01:00
|
|
|
outfile.write(content)
|