Skip to content

Commit

Permalink
Extend link detection to links outside parens (#4347)
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra committed May 4, 2024
1 parent c801cd6 commit ccfb0db
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions docs/conf.py
Expand Up @@ -34,16 +34,7 @@ def make_pypi_svg(version: str) -> None:

def replace_pr_numbers_with_links(content: str) -> str:
"""Replaces all PR numbers with the corresponding GitHub link."""

base_url = "https://github.com/psf/black/pull/"
pr_num_regex = re.compile(r"\(#(\d+)\)")

def num_to_link(match: re.Match[str]) -> str:
number = match.group(1)
url = f"{base_url}{number}"
return f"([#{number}]({url}))"

return pr_num_regex.sub(num_to_link, content)
return re.sub(r"#(\d+)", r"[#\1](https://github.com/psf/black/pull/\1)", content)


def handle_include_read(
Expand Down

0 comments on commit ccfb0db

Please sign in to comment.