diff options
| author | Zach DeCook <zachdecook@librem.one> | 2021-03-24 00:42:12 -0400 |
|---|---|---|
| committer | Zach DeCook <zachdecook@librem.one> | 2021-03-24 00:42:12 -0400 |
| commit | 8e9a836f62f1395ea4e49d08e27bbc89e29c8579 (patch) | |
| tree | f8e402eb53a6673b0adf5322985e9eb695882116 /usfm2gmi.py | |
| parent | 64a89bf77bd118a6e5a676e3a32e8061c2256ac1 (diff) | |
| download | usfm2gmi-8e9a836f62f1395ea4e49d08e27bbc89e29c8579.tar.gz | |
strongs: output code as superscript
Diffstat (limited to 'usfm2gmi.py')
| -rwxr-xr-x | usfm2gmi.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/usfm2gmi.py b/usfm2gmi.py index fb25131..43a8c87 100755 --- a/usfm2gmi.py +++ b/usfm2gmi.py @@ -21,10 +21,21 @@ def smallcaps(word): new += c return new +def superscript(word): + #TODO: also superscript lowercase letters + ss='⁰¹²³⁴⁵⁶⁷⁸⁹:;<=>?@ᴬᴮCᴰᴱFᴳᴴᶦᴶᴷᴸᴹᴺᴼᴾQᴿSᵀᵁⱽᵂ' + new = '' + for c in word: + if c >= '0' and c <= 'W': + new += ss[ord(c)-ord('0')] + else: + new += c + return new + def convert(line): """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('\\f*','\\f* ').replace('\\wj*','\\wj* ').replace('|strong',' |strong').split() + split = line.replace('\\', ' \\').replace('\\nd*','\\nd* ').replace('\\f*','\\f* ').replace('\\wj*','\\wj* ').replace('\\w*','\\w* ').split() out = '' nd = False if len(split) == 0: @@ -83,10 +94,11 @@ def convert(line): # TODO: support Endnotes (\fe and \fe*) elif word in ['\\ft']: continue # TODO: fancy formatting of more types - elif word == '\\w': - continue - elif '|strong' in word: + elif word in ['\\w','\\w*']: continue + elif '|strong="' in word: + spl = word.split('|') + out += spl[0] + superscript(spl[1][8:-1]) + ' ' else: if nd: out += smallcaps(word) + ' ' |
