def create_title(chunk, sep, tags):
    "Helper function to allow doconce jupyterbook to automatically assign titles in the TOC\n\n    If a chunk of text starts with the section specified in sep, lift it up\n    to a chapter section. This allows doconce jupyterbook to automatically use the\n    section's text as title in the TOC on the left\n\n    :param str chunk: text string\n    :param str sep: chapter|section|subsection\n    :param dict tags: tag patterns, e.g. INLINE_TAGS from common.py\n    :return: tuple with the chunk stripped of its section header, and title\n    :rtype: (str, str)\n    "
    title = ''
    m = re.search(tags[sep], chunk, flags=re.MULTILINE)
    if (m and (m.start() == 0)):
        name2s = {'chapter': 9, 'section': 7, 'subsection': 5, 'subsubsection': 3}
        s = name2s[sep]
        header_old = ('=' * s)
        pattern = ('^ *%s +(.+?) +%s' % (header_old, header_old))
        mt = re.match(pattern, chunk)
        if mt:
            title = mt.group(1)
        chunk = re.sub(pattern, '', chunk, flags=re.MULTILINE, count=1)
    return (chunk, title)
Helper function to allow doconce jupyterbook to automatically assign titles in the TOC

If a chunk of text starts with the section specified in sep, lift it up
to a chapter section. This allows doconce jupyterbook to automatically use the
section's text as title in the TOC on the left

:param str chunk: text string
:param str sep: chapter|section|subsection
:param dict tags: tag patterns, e.g. INLINE_TAGS from common.py
:return: tuple with the chunk stripped of its section header, and title
:rtype: (str, str)
def create_title(chunk, sep, tags):
    "Helper function to allow doconce jupyterbook to automatically assign titles in the TOC\n\n    If a chunk of text starts with the section specified in sep, lift it up\n    to a chapter section. This allows doconce jupyterbook to automatically use the\n    section's text as title in the TOC on the left\n\n    :param str chunk: text string\n    :param str sep: chapter|section|subsection\n    :param dict tags: tag patterns, e.g. INLINE_TAGS from common.py\n    :return: tuple with the chunk stripped of its section header, and title\n    :rtype: (str, str)\n    "
    title = 
    m = re.search(tags[sep], chunk, flags=re.MULTILINE)
    if (m and (m.start() == 0)):
        name2s = {'chapter': 9, 'section': 7, 'subsection': 5, 'subsubsection': 3}
        s = name2s[sep]
        header_old = ('=' * s)
        pattern = ('^ *%s +(.+?) +%s' % (header_old, header_old))
        mt = re.match(pattern, chunk)
        if mt:
            title = mt.group(1)
        chunk = re.sub(pattern, , chunk, flags=re.MULTILINE, count=1)
    return (chunk, title)