Commit 4190b972 authored by Marco Cavalli's avatar Marco Cavalli
Browse files

fix: Clause+++root can be used to target main clause

parent 52291eb5
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -465,6 +465,11 @@ def fix_custom_tags(soup: BeautifulSoup):
    """
    Fix custom tags in the HTML.
    """

    def notAnImage(href: str) -> bool:
        image_extensions = [".png", ".jpg", ".jpeg", ".svg"]
        return not any(href.endswith(ext) for ext in image_extensions)

    # Example: Change <custom-tag> to <div class="custom-tag">
    h1_tag = soup.find("h1", id=True)

@@ -472,10 +477,10 @@ def fix_custom_tags(soup: BeautifulSoup):

    for a in a_tags:
        href = a.get("href", "")
        if href.startswith("#") and href.find("root.") != -1: # when root. is used in md
            new_id_prefix = f"{h1_tag['id']}."
            a["href"] = href.replace("root.", new_id_prefix)
            a.string = a.string.replace("root.", new_id_prefix)
        if href.startswith("#") and href.find("root") != -1 and notAnImage(href): # when root is used in md
            new_id_prefix = f"{h1_tag['id']}"
            a["href"] = href.replace("root", new_id_prefix)
            a.string = a.string.replace("root", new_id_prefix)
        elif "below" in href:
            is_table = "Table" in href
            class_name = "TH" if is_table else "FL"