From 610310ed6259b8628e60da5ada76623eabe17bc5 Mon Sep 17 00:00:00 2001 From: bobloy Date: Wed, 2 Dec 2020 16:23:13 -0500 Subject: [PATCH] Use :doc: instead of :ref: And :any: for headers --- cogguide/cogguide.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cogguide/cogguide.py b/cogguide/cogguide.py index a58c22b..d0c4bcf 100644 --- a/cogguide/cogguide.py +++ b/cogguide/cogguide.py @@ -35,14 +35,18 @@ def markdown_link_replace(starts_with_text=None): """ def handle_starts_with_markdown_link_replace(match): - text = match.group(1) - url = match.group(2) + text: str = match.group(1) + url: str = match.group(2) if starts_with_text and url.startswith(starts_with_text): i = len(starts_with_text) url = url[i:] i = url.find(".") 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}>`_"