def convert_text_to_json(filename, output_dir, convert_all: bool, reference_prefix: str, auto: bool, verse_from: str=None, verse_to: str=None, siglum: str=None):
    filename = Path(filename).as_posix()
    if auto:
        (siglum, reference_prefix) = get_info_from_filename(filename)
    output_dir = check_and_save_dirs(output_dir, siglum)
    save_metadata(siglum, output_dir)
    text = get_file(filename)
    capture = False
    for line in text:
        line = line.split()
        if ((len(line) > 1) and line[0][0].isdigit() and line[0][(- 1)].isdigit()):
            (line, reference, verse) = format_reference(line, reference_prefix)
            if ((not convert_all) and (verse_to != verse_from)):
                if convert_this_line(verse, verse_from, verse_to):
                    capture = (not capture)
                    construct_json_transcription(line, reference, siglum, output_dir)
                elif capture:
                    construct_json_transcription(line, reference, siglum, output_dir)
            elif ((not convert_all) and (verse_from == verse_to)):
                if convert_this_line(verse, verse_from, verse_to):
                    construct_json_transcription(line, reference, siglum, output_dir)
            else:
                construct_json_transcription(line, reference, siglum, output_dir)
def convert_text_to_json(filename, output_dir, convert_all: bool, reference_prefix: str, auto: bool, verse_from: str=None, verse_to: str=None, siglum: str=None):
    filename = Path(filename).as_posix()
    if auto:
        (siglum, reference_prefix) = get_info_from_filename(filename)
    output_dir = check_and_save_dirs(output_dir, siglum)
    save_metadata(siglum, output_dir)
    text = get_file(filename)
    capture = False
    for line in text:
        line = line.split()
        if ((len(line) > 1) and line[0][0].isdigit() and line[0][(- 1)].isdigit()):
            (line, reference, verse) = format_reference(line, reference_prefix)
            if ((not convert_all) and (verse_to != verse_from)):
                if convert_this_line(verse, verse_from, verse_to):
                    capture = (not capture)
                    construct_json_transcription(line, reference, siglum, output_dir)
                elif capture:
                    construct_json_transcription(line, reference, siglum, output_dir)
            elif ((not convert_all) and (verse_from == verse_to)):
                if convert_this_line(verse, verse_from, verse_to):
                    construct_json_transcription(line, reference, siglum, output_dir)
            else:
                construct_json_transcription(line, reference, siglum, output_dir)