Use :doc: instead of :ref:

And :any: for headers
cogguide_develop
bobloy 4 years ago
parent df2ddeee24
commit 610310ed62

@ -35,14 +35,18 @@ def markdown_link_replace(starts_with_text=None):
""" """
def handle_starts_with_markdown_link_replace(match): def handle_starts_with_markdown_link_replace(match):
text = match.group(1) text: str = match.group(1)
url = match.group(2) url: str = match.group(2)
if starts_with_text and url.startswith(starts_with_text): if starts_with_text and url.startswith(starts_with_text):
i = len(starts_with_text) i = len(starts_with_text)
url = url[i:] url = url[i:]
i = url.find(".") i = url.find(".")
url = url[:i] url = url[:i]
return f":ref:`{text}<{url}>`" i = url.find("#")
if i > 0:
url = url[:i]
return f"`{text}<{url}>`" # Attempt :any: match
return f":doc:`{text}<../{url}>`"
return f"`{text} <{url}>`_" return f"`{text} <{url}>`_"

Loading…
Cancel
Save