Skip to content

Commit

Permalink
Fix HIX value diff when page content has nested tags
Browse files Browse the repository at this point in the history
  • Loading branch information
seluianova committed Feb 12, 2024
1 parent 46bfc49 commit 328bc5d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion integreat_cms/cms/views/utils/hix.py
Expand Up @@ -42,7 +42,7 @@ def normalize_text(text: str) -> str:
root = fromstring(text)

# Remove paragraphs without text (e.g. empty paragraphs or with an image only)
for node in root.iter():
for node in list(root):
node_text = node.text_content()
if not node_text or not node_text.strip():
node.getparent().remove(node)
Expand Down
2 changes: 2 additions & 0 deletions integreat_cms/release_notes/current/unreleased/2652.yml
@@ -0,0 +1,2 @@
en: Fix HIX value diff when page content has nested tags
de: Behebe HIX-Wert-Differenz, wenn Seiteninhalt verschachtelte Tags hat
6 changes: 3 additions & 3 deletions tests/textlab_api/textlab_config.py
Expand Up @@ -8,8 +8,8 @@
"<p><strong>One</strong> paragraph</p>",
),
(
"<p>One paragraph</p><p>&nbsp;&nbsp;</p><p>&nbsp;</p>",
"<p>One paragraph</p>",
"<p><strong>One</strong> paragraph</p><p>&nbsp;&nbsp;</p><p>&nbsp;</p>",
"<p><strong>One</strong> paragraph</p>",
),
(
"<div><p>One paragraph</p></div>",
Expand Down Expand Up @@ -56,7 +56,7 @@
'<p><a href="some.url">Some link</a></p>',
),
(
'<div><p>Some image</p><p><a href="some.image"><img src="some.image" alt=""></a></p></div>',
'<div><p>Some image</p><p><a href="some.image"><img src="some.image" alt=""></a></p><p>&nbsp;</p></div>',
"<p>Some image</p>",
),
(
Expand Down

0 comments on commit 328bc5d

Please sign in to comment.