fix(seautils): fix table of contents in rfc documents

This commit is contained in:
Seaswimmer 2024-05-28 21:16:10 -04:00
parent 42e209b547
commit 8d3f5c1d5f
Signed by untrusted user: cswimr
GPG key ID: 5D671B5D03D65A7F

View file

@ -29,8 +29,10 @@ from redbot.core.utils.views import SimpleMenu
def md(soup: BeautifulSoup, **options) -> Any | str: def md(soup: BeautifulSoup, **options) -> Any | str:
return MarkdownConverter(**options).convert_soup(soup) return MarkdownConverter(**options).convert_soup(soup)
def convert_rfc_references(text: str): def convert_rfc_references(text: str, number: int) -> str:
return re.sub(r"\(\.\/rfc(\d+)", r"(https://www.rfc-editor.org/rfc/rfc\1.html", text) 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): class SeaUtils(commands.Cog):
"""A collection of random utilities.""" """A collection of random utilities."""