#!/usr/bin/env python3 # pip3 install bible-passage-reference-parser from bible import parse_string import os import sys def printf(line): if line.strip(): notref = ' '.join(line.split(' ')[2:]).strip() notref = notref.replace('||', "\n") print(notref, end='\n') else: print() def eprint(*args, **kwargs): print(*args, file=sys.stderr, **kwargs) def main(qs): if not qs: print("10 Enter a scripture reference\r\n") return passages = parse_string(qs) # TODO: Also handle "john 3, tomato 2" errors? if type(passages[0]) == tuple: print("51 " + str(passages[0][0]) + "'\r\n") return print("20 text/gemini\r\n") printlsv(passages) def printlsv(passages, title = True, plug=True): if plug: print("=> https://www.lsvbible.com/p/get-lsv.html Literal Standard Version text from lsvbible.com (CC-BY-SA)") for passage in passages: if title: print("# " + passage.format()) printing = False f = open('lsv.txt') startmark = passage.start.format('a')[0:3]+" "+passage.start.format('c:v') eprint(startmark) endmark = passage.end.format('a')[0:3]+" "+passage.end.format('c:v') for line in f: if (startmark+' ') in line: printing = True if (endmark + ' ') in line: printf(line) printing = False if printing: printf(line) print('(LSV)') #end in newline if __name__ == '__main__': qs = os.getenv("QUERY_STRING") or (sys.argv[1] if len(sys.argv) >= 2 else '') main(qs)