40 lines
1.5 KiB
Python
40 lines
1.5 KiB
Python
import sys
|
|
import re
|
|
|
|
for filename in sys.argv[1:]:
|
|
with open(filename, 'r') as infile:
|
|
content = infile.readlines()
|
|
|
|
|
|
to_use = content.pop(0).replace('|',', ')
|
|
html_header = 'volabula: ' + ''.join(to_use) + '<br>'
|
|
# Replace _string_ with html
|
|
html_span_head = '<span>'
|
|
html_input_head = '<input type="text" data-expected="'
|
|
html_input_tail = '"/>'
|
|
html_span_tail = '</span>'
|
|
for i in range(len(content)):
|
|
content[i] = 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[i].rstrip('\n'))
|
|
# Replace vowel-dash-vowel with vowels with macrons
|
|
content[i] = content[i].replace('A-A', 'Ā')
|
|
content[i] = content[i].replace('a-a', 'ā')
|
|
content[i] = content[i].replace('E-E', 'Ē')
|
|
content[i] = content[i].replace('e-e', 'ē')
|
|
content[i] = content[i].replace('I-I', 'Ī')
|
|
content[i] = content[i].replace('i-i', 'ī')
|
|
content[i] = content[i].replace('O-O', 'Ō')
|
|
content[i] = content[i].replace('o-o', 'ō')
|
|
content[i] = content[i].replace('U-U', 'Ū')
|
|
content[i] = content[i].replace('u-u', 'ū')
|
|
|
|
html_list_header = '<ol>\n'
|
|
html_list_element_header = '<li>'
|
|
html_list_element_trailer = '</li>\n'
|
|
html_list_trailer = '</ol>'
|
|
|
|
with open(filename + '.html', 'w') as outfile:
|
|
outfile.write(html_header)
|
|
outfile.write(html_list_header)
|
|
for line in content:
|
|
outfile.write(html_list_element_header + line.rstrip('\n') + html_list_element_trailer)
|
|
outfile.write(html_list_trailer) |