def titles_to_chunks(chunks, title_list, sep, sep2=None, chapter_formatter='%02d_', tags=INLINE_TAGS):
    'Helper function to extract assign titles to jupyter-book chapters/sections (here called chunks)\n\n    Jupyter-book files must have a # header with the title (see doc jupyter-book >\n    Types of content source files > Rules for all content types). This function\n    extracts title from the title file or from the headers given by the separator\n    provided in the options. If no title is found, provide a default title as e.g.\n    03_mydoconcefile.\n\n    :param list[str] chunks: list of text string\n    :param list[str] title_list: titles for the chunks. Empty if --titles is us\n    :param str sep: separator: chapter|section|subsection\n    :param str sep2: second separator in case the first fails: chapter|section|subsection\n    :param dict tags: tag patterns, e.g. INLINE_TAGS from common.py\n    :param str chapter_formatter: formatter for default filenames\n    :return: tuple with the chunks of text having a # header, titles, titles detected\n    :rtype: (list[str], list[str], list[str])\n    '
    title_list_out = title_list.copy()
    if (not len(title_list_out)):
        title_list_out = ([''] * len(chunks))
    title_list_detected = ([''] * len(chunks))
    for (i, chunk) in enumerate(chunks):
        title = ''
        if (title == ''):
            (chunk, title) = create_title(chunk, sep, tags)
        if ((title == '') and sep2):
            (chunk, title) = create_title(chunk, sep2, tags)
        if (title == ''):
            title = ((chapter_formatter % (i + 1)) + globals.dofile_basename)
        title_list_detected[i] = title
        if (i < len(title_list)):
            if title_list[i]:
                title = title_list[i]
        title_list_out[i] = title
        chunk = ((((((('=' * 9) + ' ') + title) + ' ') + ('=' * 9)) + '\n') + chunk)
        chunks[i] = chunk
    return (chunks, title_list_out, title_list_detected)
Helper function to extract assign titles to jupyter-book chapters/sections (here called chunks)

Jupyter-book files must have a # header with the title (see doc jupyter-book >
Types of content source files > Rules for all content types). This function
extracts title from the title file or from the headers given by the separator
provided in the options. If no title is found, provide a default title as e.g.
03_mydoconcefile.

:param list[str] chunks: list of text string
:param list[str] title_list: titles for the chunks. Empty if --titles is us
:param str sep: separator: chapter|section|subsection
:param str sep2: second separator in case the first fails: chapter|section|subsection
:param dict tags: tag patterns, e.g. INLINE_TAGS from common.py
:param str chapter_formatter: formatter for default filenames
:return: tuple with the chunks of text having a # header, titles, titles detected
:rtype: (list[str], list[str], list[str])
def titles_to_chunks(chunks, title_list, sep, sep2=None, chapter_formatter='%02d_', tags=INLINE_TAGS):
    'Helper function to extract assign titles to jupyter-book chapters/sections (here called chunks)\n\n    Jupyter-book files must have a # header with the title (see doc jupyter-book >\n    Types of content source files > Rules for all content types). This function\n    extracts title from the title file or from the headers given by the separator\n    provided in the options. If no title is found, provide a default title as e.g.\n    03_mydoconcefile.\n\n    :param list[str] chunks: list of text string\n    :param list[str] title_list: titles for the chunks. Empty if --titles is us\n    :param str sep: separator: chapter|section|subsection\n    :param str sep2: second separator in case the first fails: chapter|section|subsection\n    :param dict tags: tag patterns, e.g. INLINE_TAGS from common.py\n    :param str chapter_formatter: formatter for default filenames\n    :return: tuple with the chunks of text having a # header, titles, titles detected\n    :rtype: (list[str], list[str], list[str])\n    '
    title_list_out = title_list.copy()
    if (not len(title_list_out)):
        title_list_out = ([] * len(chunks))
    title_list_detected = ([] * len(chunks))
    for (i, chunk) in enumerate(chunks):
        title = 
        if (title == ):
            (chunk, title) = create_title(chunk, sep, tags)
        if ((title == ) and sep2):
            (chunk, title) = create_title(chunk, sep2, tags)
        if (title == ):
            title = ((chapter_formatter % (i + 1)) + globals.dofile_basename)
        title_list_detected[i] = title
        if (i < len(title_list)):
            if title_list[i]:
                title = title_list[i]
        title_list_out[i] = title
        chunk = ((((((('=' * 9) + ' ') + title) + ' ') + ('=' * 9)) + '\n') + chunk)
        chunks[i] = chunk
    return (chunks, title_list_out, title_list_detected)