def convert_rst_links()

in utils/convert_doc_to_notebooks.py [0:0]


def convert_rst_links(text):
    """ Convert the rst links in text to markdown."""
    # Links of the form :doc:`page`
    text = _re_simple_doc.sub(r'[\1](' + DOC_BASE_URL + r'\1.html)', text)
    # Links of the form :doc:`text <page>`
    text = _re_doc_with_description.sub(r'[\1](' + DOC_BASE_URL + r'\2.html)', text)
    # Refs of the form :ref:`page`
    text = _re_simple_ref.sub(r'[\1](#\1)', text)
    # Refs of the form :ref:`text <page>`
    text = _re_ref_with_description.sub(r'[\1](#\2)', text)
    # Other links
    def _rep_links(match):
        text,url = match.groups()
        if not url.startswith('http'):
            url = DOC_BASE_URL + url
        return f"[{text}]({url})"
    text = _re_links.sub(_rep_links, text)
    return text