Loading md_to_docx_converter/src/to_html/postprocessing.py +9 −4 Original line number Diff line number Diff line Loading @@ -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) Loading @@ -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" Loading Loading
md_to_docx_converter/src/to_html/postprocessing.py +9 −4 Original line number Diff line number Diff line Loading @@ -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) Loading @@ -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" Loading