Convert usfm bibles into gemtext (python library/utility)
convert: add option to output strongs numbers
| -rwxr-xr-x | usfm2gmi.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/usfm2gmi.py b/usfm2gmi.py index 222d800..afb6834 100755 --- a/usfm2gmi.py +++ b/usfm2gmi.py @@ -32,7 +32,7 @@ def superscript(word): new += c return new -def convert(line): +def convert(line, printStrongs=False): """Convert a string to a list of tuples, each a token""" # TODO: preserve the lack of whitespace before a backslash. split = line.replace('\\', ' \\').replace('\\nd*','\\nd* ').replace('\\+nd*','\\+nd* ').replace('\\f*','\\f* ').replace('\\wj*','\\wj* ').replace('\\w*',' \\w* ').replace('\\+w*', '\\+w* ').split() @@ -113,7 +113,10 @@ def convert(line): continue elif '|strong="' in word: spl = word.split('|') - out += spl[0] + ' ' #superscript(spl[1][8:-1]) + ' ' + out += spl[0] + if printStrongs: + out += superscript(spl[1][8:-1]) + out += ' ' # Remove those extra spaces that sneak in. elif word in [',', '.', ';', '”', ',”', '.”', '?”', ')', ':', '!', '?', '.’', '.’”', '?’”', '?’', ';”', '!”', ');', '),']: if out[-1] == ' ': |