def split_file(filestr, separator):
    "Split the text of a doconce file by a regex string.\n\n    Split the text of a doconce file by a separator regex (e.g. the values of\n    the INLINE_TAGS dictionary from common.py) and return the chunks of text.\n    Note that the first chunk contains any text before the first separator.\n    :param str filestr: text string\n    :param str separator: regex text, e.g. INLINE_TAGS['chapter'], see common.py\n    :return: list of text chunks\n    :rtype: list[str]\n    "
    chunks = []
    c = re.compile(separator, flags=re.MULTILINE)
    if (re.search(c, filestr) is None):
        print('pattern of separator not found in file')
        chunks.append(filestr)
    else:
        pos_prev = 0
        for m in re.finditer(c, filestr):
            if (m.start() == 0):
                continue
            if (filestr[:m.start()].rfind('!bc') > filestr[:m.start()].rfind('!ec')):
                errwarn('*** warning : skipped a separator, which appeared to be inside the !bc and !ec directives')
                continue
            chunk = filestr[pos_prev:m.start()]
            chunks.append(chunk)
            pos_prev = m.start()
        chunk = filestr[pos_prev:]
        chunks.append(chunk)
    return chunks
Split the text of a doconce file by a regex string.

Split the text of a doconce file by a separator regex (e.g. the values of
the INLINE_TAGS dictionary from common.py) and return the chunks of text.
Note that the first chunk contains any text before the first separator.
:param str filestr: text string
:param str separator: regex text, e.g. INLINE_TAGS['chapter'], see common.py
:return: list of text chunks
:rtype: list[str]
def split_file(filestr, separator):
    "Split the text of a doconce file by a regex string.\n\n    Split the text of a doconce file by a separator regex (e.g. the values of\n    the INLINE_TAGS dictionary from common.py) and return the chunks of text.\n    Note that the first chunk contains any text before the first separator.\n    :param str filestr: text string\n    :param str separator: regex text, e.g. INLINE_TAGS['chapter'], see common.py\n    :return: list of text chunks\n    :rtype: list[str]\n    "
    chunks = []
    c = re.compile(separator, flags=re.MULTILINE)
    if (re.search(c, filestr) is None):
        print('pattern of separator not found in file')
        chunks.append(filestr)
    else:
        pos_prev = 0
        for m in re.finditer(c, filestr):
            if (m.start() == 0):
                continue
            if (filestr[:m.start()].rfind('!bc') > filestr[:m.start()].rfind('!ec')):
                errwarn('*** warning : skipped a separator, which appeared to be inside the !bc and !ec directives')
                continue
            chunk = filestr[pos_prev:m.start()]
            chunks.append(chunk)
            pos_prev = m.start()
        chunk = filestr[pos_prev:]
        chunks.append(chunk)
    return chunks