diff --git a/docs/build_docs.py b/docs/build_docs.py index a2c13ab6..23e668dc 100644 --- a/docs/build_docs.py +++ b/docs/build_docs.py @@ -37,6 +37,7 @@ from tqdm import tqdm os.environ["JUPYTER_PLATFORM_DIRS"] = "1" # fix DeprecationWarning: Jupyter is migrating to use standard platformdirs DOCS = Path(__file__).parent.resolve() SITE = DOCS.parent / "site" +LINK_PATTERN = re.compile(r"(https?://[^\s()<>]*[^\s()<>.,:;!?\'\"])") def create_vercel_config(): @@ -72,7 +73,6 @@ def prepare_docs_markdown(clone_repos=True): def update_page_title(file_path: Path, new_title: str): """Update the title of an HTML file.""" - # Read the content of the file with open(file_path, encoding="utf-8") as file: content = file.read() @@ -206,11 +206,7 @@ def convert_plaintext_links_to_html(content): for paragraph in main_content.find_all(["p", "li"]): # Focus on paragraphs and list items 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'\1', - str(text_node), - ) + new_text = LINK_PATTERN.sub(r'\1', str(text_node)) if "