Convert usfm bibles into gemtext (python library/utility)
nd: Make God's name in smallcaps
| -rwxr-xr-x | usfm2gmi.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/usfm2gmi.py b/usfm2gmi.py index 806b94f..0337153 100755 --- a/usfm2gmi.py +++ b/usfm2gmi.py @@ -4,11 +4,23 @@ import fileinput def printf(string): print(string,end='') +def smallcaps(word): + sc = 'ᴀʙᴄᴅᴇғɢʜɪᴊᴋʟᴍɴᴏᴘǫʀsᴛᴜᴠᴡxʏᴢ' + new = '' + for c in word: + if c >= 'a' and c <= 'z': + # I like C programming. + new += sc[ord(c)-ord('a')] + 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('\\', ' \\').split() out = '' + nd = False if len(split) == 0: return out elif split[0] in ['\\mt1','\\mt','\\ms']: @@ -35,7 +47,14 @@ def convert(line): out += '\n> ' elif word in ['\\wj','\\wj*']: continue + elif word == '\\nd': + nd = True + elif word == '\\nd*': + nd = False else: + if nd: + out += smallcaps(word) + ' ' + else: out += word + ' ' return out |