def resolve_links_destinations(chunks, chunk_basenames):
    'Fix links in jupyter-book chapters/sections so that they can target destinations in other files\n\n    Prepend a filename to all links\' destinations e.g. <a href="#Langtangen_2012"> becomes\n    <a href="02_jupyterbook.html#Langtangen_2012">\n    :param list[str] chunks: DocOnce texts consisting in Jupyter-book chapters/sections\n    :param list[str] chunk_basenames: file basenames for jupyter-book chapters/sections\n    :return: chunks with corrected links\n    :rtype: Tuple[list[str], list[list[str]]]\n    '

    def strip_end(text, suffix):
        if (suffix and text.endswith(suffix)):
            return text[:(- len(suffix))]
        return text
    all_sects = chunks
    all_basenames = chunk_basenames
    all_basenames = list(map((lambda fname: strip_end(fname, '.md')), all_basenames))
    all_basenames = list(map((lambda fname: strip_end(fname, '.ipynb')), all_basenames))
    tag2file = {}
    for i in range(len(all_sects)):
        (ch_destinations, ch_destination_tags) = get_link_destinations(all_sects[i])
        basename_list = ([all_basenames[i]] * len(ch_destinations))
        tag2file.update(zip(ch_destination_tags, basename_list))
    for c in range(len(chunks)):
        chunks[c] = fix_links(chunks[c], tag2file)
    return chunks
Fix links in jupyter-book chapters/sections so that they can target destinations in other files

Prepend a filename to all links' destinations e.g. <a href="#Langtangen_2012"> becomes
<a href="02_jupyterbook.html#Langtangen_2012">
:param list[str] chunks: DocOnce texts consisting in Jupyter-book chapters/sections
:param list[str] chunk_basenames: file basenames for jupyter-book chapters/sections
:return: chunks with corrected links
:rtype: Tuple[list[str], list[list[str]]]
def resolve_links_destinations(chunks, chunk_basenames):
    'Fix links in jupyter-book chapters/sections so that they can target destinations in other files\n\n    Prepend a filename to all links\' destinations e.g. <a href="#Langtangen_2012"> becomes\n    <a href="02_jupyterbook.html#Langtangen_2012">\n    :param list[str] chunks: DocOnce texts consisting in Jupyter-book chapters/sections\n    :param list[str] chunk_basenames: file basenames for jupyter-book chapters/sections\n    :return: chunks with corrected links\n    :rtype: Tuple[list[str], list[list[str]]]\n    '

    def strip_end(text, suffix):
        if (suffix and text.endswith(suffix)):
            return text[:(- len(suffix))]
        return text
    all_sects = chunks
    all_basenames = chunk_basenames
    all_basenames = list(map((lambda fname: strip_end(fname, '.md')), all_basenames))
    all_basenames = list(map((lambda fname: strip_end(fname, '.ipynb')), all_basenames))
    tag2file = {}
    for i in range(len(all_sects)):
        (ch_destinations, ch_destination_tags) = get_link_destinations(all_sects[i])
        basename_list = ([all_basenames[i]] * len(ch_destinations))
        tag2file.update(zip(ch_destination_tags, basename_list))
    for c in range(len(chunks)):
        chunks[c] = fix_links(chunks[c], tag2file)
    return chunks