Fix MNIST link (#17038)

Signed-off-by: UltralyticsAssistant <web@ultralytics.com>
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
Paula Derrenger 2024-10-19 23:43:12 +02:00 committed by GitHub
parent e107611294
commit ab697b327b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

View file

@ -199,11 +199,12 @@ def convert_plaintext_links_to_html(content):
for text_node in paragraph.find_all(string=True, recursive=False):
if text_node.parent.name not in {"a", "code"}: # Ignore links and code blocks
new_text = re.sub(
r"(https?://[^\s()<>]*[^\s()<>.,:;!?])",
r"(https?://[^\s()<>]*[^\s()<>.,:;!?\'\"])",
r'<a href="\1">\1</a>',
str(text_node),
)
if "<a href=" in new_text:
# Parse the new text with BeautifulSoup to handle HTML properly
new_soup = BeautifulSoup(new_text, "html.parser")
text_node.replace_with(new_soup)
modified = True