diff options
| author | Zach DeCook <zachdecook@librem.one> | 2021-02-25 19:33:37 -0500 |
|---|---|---|
| committer | Zach DeCook <zachdecook@librem.one> | 2021-02-25 19:33:37 -0500 |
| commit | 49d66b2139ceb2f87cd878a62b8bccbe5d19d323 (patch) | |
| tree | a7224ceef1d684a11da7404bb18fce1005da50ed /usfm2gmi.py | |
| parent | 213f0d4d2083ff68556f4fc6af0db898507fab19 (diff) | |
| download | usfm2gmi-49d66b2139ceb2f87cd878a62b8bccbe5d19d323.tar.gz | |
Footnotes: basic support
Diffstat (limited to 'usfm2gmi.py')
| -rwxr-xr-x | usfm2gmi.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/usfm2gmi.py b/usfm2gmi.py index 90c18ae..aca2e26 100755 --- a/usfm2gmi.py +++ b/usfm2gmi.py @@ -18,7 +18,7 @@ def smallcaps(word): 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* ').split() + split = line.replace('\\', ' \\').replace('\\nd*','\\nd* ').replace('\\f*','\\f* ').split() out = '' nd = False if len(split) == 0: @@ -53,6 +53,17 @@ def convert(line): nd = True elif word == '\\nd*': nd = False + # Footnotes (https://ubsicap.github.io/usfm/notes_basic/fnotes.html) + elif word == '\\f': + out += '[' + skip = 1 # the next character is the footnote caller + elif word == '\\fr': + skip = 1 # verse reference not necessary for inline fn + elif word == '\\f*': + out += ']' + # TODO: support Endnotes (\fe and \fe*) + elif word in ['\\ft']: + continue # TODO: fancy formatting of more types else: if nd: out += smallcaps(word) + ' ' |
