def create_toc_yml(basenames, nesting_levels, titles, dest='./', dest_toc='./', section_paths=None, section_titles=None):
    'Create the content of a _toc.yml file\n\n        Give the lists of paths, titles, and nesting levels, return the content of a _toc.yml file\n        :param list[str] basenames: list of file basenames for jupyter-book chapters or sections, i.e.\n        strings that can be used after the `file:` section in a _toc.yml\n        :param list[str] titles: list of titles to jupyter-book chapters, i.e. strings that can be used\n        after the `title:` section in a _toc.yml\n        :param list[str] nesting_levels: nesting levels for basenames and titles: # 0 or 1 for jupyter-book\n        chapters or sections, respectively\n        :param str dest: destination folder for _toc.yml\n        :param str dest_toc: destination folder for the chapter files\n        :return: content of a _toc.yml file\n        :rtype: str\n    '

    def escape_chars(title):
        'Wrap title in quotes if it contains colons, asterisks, bacticks'
        if (re.search(':', title) or re.search('\\*', title) or re.search('\\`', title)):
            title = title.replace('"', '\\"')
            title = (('"' + title) + '"')
        return title
    relpath = os.path.relpath(dest, start=dest_toc)
    if (relpath == '.'):
        relpath = ''
    else:
        relpath += '/'
    yml_text = ''
    nesting_prev = 0
    for (i, cfname) in enumerate(basenames):
        ctitle = escape_chars(titles[i])
        if ctitle:
            nesting = nesting_levels[i]
            if (nesting == 0):
                yml_text += '\n'
                yml_text += yml_titledpage((relpath + cfname), ctitle, numbered=False)
            else:
                if (nesting_prev == 0):
                    yml_text += yml_section(nesting_level=nesting)
                yml_text += yml_nested_section((relpath + cfname), ctitle, nesting_level=nesting)
        nesting_prev = nesting
    yml_text = yml_text.strip('\n')
    return yml_text
Create the content of a _toc.yml file

Give the lists of paths, titles, and nesting levels, return the content of a _toc.yml file
:param list[str] basenames: list of file basenames for jupyter-book chapters or sections, i.e.
strings that can be used after the `file:` section in a _toc.yml
:param list[str] titles: list of titles to jupyter-book chapters, i.e. strings that can be used
after the `title:` section in a _toc.yml
:param list[str] nesting_levels: nesting levels for basenames and titles: # 0 or 1 for jupyter-book
chapters or sections, respectively
:param str dest: destination folder for _toc.yml
:param str dest_toc: destination folder for the chapter files
:return: content of a _toc.yml file
:rtype: str
def create_toc_yml(basenames, nesting_levels, titles, dest='./', dest_toc='./', section_paths=None, section_titles=None):
    'Create the content of a _toc.yml file\n\n        Give the lists of paths, titles, and nesting levels, return the content of a _toc.yml file\n        :param list[str] basenames: list of file basenames for jupyter-book chapters or sections, i.e.\n        strings that can be used after the `file:` section in a _toc.yml\n        :param list[str] titles: list of titles to jupyter-book chapters, i.e. strings that can be used\n        after the `title:` section in a _toc.yml\n        :param list[str] nesting_levels: nesting levels for basenames and titles: # 0 or 1 for jupyter-book\n        chapters or sections, respectively\n        :param str dest: destination folder for _toc.yml\n        :param str dest_toc: destination folder for the chapter files\n        :return: content of a _toc.yml file\n        :rtype: str\n    '

    def escape_chars(title):
        'Wrap title in quotes if it contains colons, asterisks, bacticks'
        if (re.search(':', title) or re.search('\\*', title) or re.search('\\`', title)):
            title = title.replace('"', '\\"')
            title = (('"' + title) + '"')
        return title
    relpath = os.path.relpath(dest, start=dest_toc)
    if (relpath == '.'):
        relpath = 
    else:
        relpath += '/'
    yml_text = 
    nesting_prev = 0
    for (i, cfname) in enumerate(basenames):
        ctitle = escape_chars(titles[i])
        if ctitle:
            nesting = nesting_levels[i]
            if (nesting == 0):
                yml_text += '\n'
                yml_text += yml_titledpage((relpath + cfname), ctitle, numbered=False)
            else:
                if (nesting_prev == 0):
                    yml_text += yml_section(nesting_level=nesting)
                yml_text += yml_nested_section((relpath + cfname), ctitle, nesting_level=nesting)
        nesting_prev = nesting
    yml_text = yml_text.strip('\n')
    return yml_text