diff --git a/README.md b/README.md index 889f49b..fb842e2 100644 --- a/README.md +++ b/README.md @@ -12,14 +12,10 @@ As I've started learning Latin from Lingua Latina Per Se Illustrata I've encourt - underscore-string-underscore combinations (```_us_```) are transformed intorequiered html text input field with string between underscores as a value of ```data-expected``` atribute (``````). # TODO - - [ ] text to html parser to swiftly migrate the cloze Pensa + - [x] text to html parser to swiftly migrate the cloze Pensa - [ ] dictionairy interface - [ ] # Development -To run the app on your own machine: -1. ```pipenv shell``` -2. ```export FLASK_APP=main.py``` -3. ```export FLASK_ENV=development``` -4. ```flask run``` \ No newline at end of file +To run the app on your own machine use ```pipenv shell 'flask run'```. \ No newline at end of file diff --git a/text2pensum.py b/text2pensum.py old mode 100755 new mode 100644 index 66515d1..b387ae7 --- a/text2pensum.py +++ b/text2pensum.py @@ -1,25 +1,26 @@ import sys import re -with open(sys.argv[1], 'r') as infile: - content = infile.read() +for filename in sys.argv[1:]: + with open(filename, 'r') as infile: + content = infile.read() -# Replace _string_ with html -html_head = '' -content = re.sub(r'_([a-zA-Z\-]+)_', html_head+r'\1'+html_tail, content) + # Replace _string_ with html + html_head = '' + content = re.sub(r'_([a-zA-Z\-]+)_', html_head+r'\1'+html_tail, content) -# 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', 'ū') + # 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', 'ū') -with open(sys.argv[1] + '.html', 'w+') as outfile: - outfile.write(content) \ No newline at end of file + with open(filename + '.html', 'w+') as outfile: + outfile.write(content) \ No newline at end of file