diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 127c0c5c..35b94746 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,9 @@ repos: - id: check-merge-conflict - id: check-yaml - id: end-of-file-fixer + exclude: ^core/tests/content/boost_release[a-zA-Z_]+.html - id: trailing-whitespace + exclude: ^core/tests/content/boost_release[a-zA-Z_]+.html - repo: https://github.com/ambv/black rev: 23.3.0 hooks: diff --git a/core/htmlhelper.py b/core/htmlhelper.py index e01e0565..4c1c3a5d 100644 --- a/core/htmlhelper.py +++ b/core/htmlhelper.py @@ -45,6 +45,7 @@ REMOVE_TAGS = [ # very prominent header # /docs/libs/1_82_0/libs/locale/doc/html/index.html ("div", {"id": "top"}), + ("div", {"id": "footer"}), # almost every other page has this as a header ("table", {"cellpadding": "2", "width": "100%"}), ] diff --git a/core/tests/content/boost_release_notes_filtered_output.html b/core/tests/content/boost_release_notes_filtered_output.html new file mode 100644 index 00000000..52d8b4cb --- /dev/null +++ b/core/tests/content/boost_release_notes_filtered_output.html @@ -0,0 +1,23 @@ +

Version 1.20.1

January 10th, 2001 12:00 GMT

\ No newline at end of file diff --git a/core/tests/content/boost_release_notes_sample.html b/core/tests/content/boost_release_notes_sample.html new file mode 100644 index 00000000..5154a596 --- /dev/null +++ b/core/tests/content/boost_release_notes_sample.html @@ -0,0 +1,101 @@ + + + + + Version 1.20.1 + + + + + + + + + + +
+
+ +
+
+
+
+
+
+

Version 1.20.1

+
+ +
+

Version 1.20.1

+ +

January 10th, 2001 12:00 GMT

+ + +
+
+ + + +
+
+
+
+
+
+ + + +
+
+
+ + + + diff --git a/core/tests/test_htmlhelper.py b/core/tests/test_htmlhelper.py index e7fe9bd3..2e1e9114 100644 --- a/core/tests/test_htmlhelper.py +++ b/core/tests/test_htmlhelper.py @@ -17,9 +17,9 @@ from core.htmlhelper import ( remove_tables, remove_tags, style_links, + modernize_release_notes, ) - BASE_HEAD = """ @@ -764,3 +764,14 @@ def test_style_links_no_links(): # Assertions for a_tag in soup.find_all("a"): assert new_class_name in a_tag.get("class", []), "Class not added to link" + + +def test_modernize_release_notes(): + content = open("core/tests/content/boost_release_notes_sample.html", "rb").read() + output = modernize_release_notes(content) + expected_output = ( + open("core/tests/content/boost_release_notes_filtered_output.html") + .read() + .strip() + ) + assert output == expected_output