From 8d3f5c1d5facc078854894ae2fdd4bcd20c5d00a Mon Sep 17 00:00:00 2001 From: Seaswimmer Date: Tue, 28 May 2024 21:16:10 -0400 Subject: [PATCH] fix(seautils): fix table of contents in rfc documents --- seautils/seautils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/seautils/seautils.py b/seautils/seautils.py index 146384f..649a875 100644 --- a/seautils/seautils.py +++ b/seautils/seautils.py @@ -29,8 +29,10 @@ from redbot.core.utils.views import SimpleMenu def md(soup: BeautifulSoup, **options) -> Any | str: return MarkdownConverter(**options).convert_soup(soup) -def convert_rfc_references(text: str): - return re.sub(r"\(\.\/rfc(\d+)", r"(https://www.rfc-editor.org/rfc/rfc\1.html", text) +def convert_rfc_references(text: str, number: int) -> str: + one = re.sub(r"\(\.\/rfc(\d+)", r"(https://www.rfc-editor.org/rfc/rfc\1.html", text) + two = re.sub(r"\((#(?:section|page)-\d+)\)", f"https://www.rfc-editor.org/rfc/rfc{number}.html\1", one) + return two class SeaUtils(commands.Cog): """A collection of random utilities."""