Convert usfm bibles into gemtext (python library/utility)
enable superscript tag
Zach DeCook 2023-12-12
parent 457f85f · commit a9e497d
-rwxr-xr-xusfm2gmi.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/usfm2gmi.py b/usfm2gmi.py
index 5d52808..6865ac4 100755
--- a/usfm2gmi.py
+++ b/usfm2gmi.py
@@ -38,6 +38,7 @@ def convert(line, printStrongs=False):
split = line.replace('\\', ' \\').replace('\\nd*','\\nd* ').replace('\\+nd*','\\+nd* ').replace('\\f*','\\f* ').replace('\\wj*','\\wj* ').replace('\\w*',' \\w* ').replace('\\+w*', '\\+w* ').split()
out = ''
nd = False
+ superS = False
if len(split) == 0:
return out
elif split[0] in ['\\mt1','\\mt','\\ms','\\h']:
@@ -111,6 +112,10 @@ def convert(line, printStrongs=False):
continue
elif word in ['\\nb']:
continue
+ elif word == '\\+sup':
+ superS = True
+ elif word == '\\+sup*':
+ superS = False
elif '|strong="' in word:
spl = word.split('|')
out += spl[0]
@@ -130,6 +135,8 @@ def convert(line, printStrongs=False):
else:
if nd:
out += smallcaps(word) + ' '
+ if superS:
+ out += superscript(word) + ' '
else:
out += word + ' '
return out