From 10d30cc5809305002cc2648d7c54acbc604bb578 Mon Sep 17 00:00:00 2001 From: Greg Kaleka Date: Tue, 8 Apr 2025 17:40:55 -0400 Subject: [PATCH] Fix an issue with docs boostlook wrapper div (#1732) --- core/htmlhelper.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/core/htmlhelper.py b/core/htmlhelper.py index 846d2a31..a6f7eaa8 100644 --- a/core/htmlhelper.py +++ b/core/htmlhelper.py @@ -4,7 +4,7 @@ from bs4 import BeautifulSoup, Comment from django.template.loader import render_to_string from core.boostrenderer import get_body_from_html - +from core.constants import SourceDocType # List HTML elements (with relevant attributes) to remove the FIRST occurrence REMOVE_TAGS = [ @@ -118,18 +118,25 @@ def _replace_body(result, original_body, base_body): result.body.body.unwrap() -def wrap_main_body_elements(result, original_docs_type=None): - def is_end_comment(element): +def wrap_main_body_elements( + result: BeautifulSoup, original_docs_type: SourceDocType | None = None +): + def is_end_comment(html_element): return ( - isinstance(element, Comment) and element == " END Manually appending items " + isinstance(html_element, Comment) + and html_element == " END Manually appending items " ) start_index = None elements_to_wrap = [] - wrapper_div = result.new_tag("div", id="todo-remove-boost-legacy-docs-wrapper") + wrapper_div = result.new_tag("div") if original_docs_type: - # add a class based on the original docs type - wrapper_div["class"] = f"source-docs-{original_docs_type.value} boostlook" + # add classes based on the original docs type + class_list = [f"source-docs-{original_docs_type.value}"] + if original_docs_type != SourceDocType.ANTORA: + # Antora docs have a boostlook class already; others need it. + class_list.append("boostlook") + wrapper_div["class"] = " ".join(class_list) for index, element in enumerate(result.find("body").children): if is_end_comment(element): start_index = index @@ -149,7 +156,7 @@ def modernize_legacy_page( base_html, head_selector="head", insert_body=True, - original_docs_type=None, + original_docs_type: SourceDocType | None = None, skip_replace_boostlook=False, show_footer=True, show_navbar=True,