Skip to content

[18.0][FIX] html_text: keep words of adjacent blocks apart - #3871

Open
GebleaAlex wants to merge 1 commit into
OCA:18.0from
GebleaAlex:18.0-fix-html_text-block-elements
Open

GebleaAlex wants to merge 1 commit into
OCA:18.0from
GebleaAlex:18.0-fix-html_text-block-elements

Conversation

@GebleaAlex

Copy link
Copy Markdown

text_from_html() joins all text nodes without a separator, so the words of adjacent block elements are glued together:

  • <p>First</p><p>Second</p> -> FirstSecond
  • <p>One<br>Two</p> -> OneTwo
  • <ul><li>a</li><li>b</li></ul> -> ab

The HTML editor stores content like this, with no whitespace between blocks. The existing test only passes because its HTML has newlines between the tags.

The fix adds a space around block elements and <br> before the words are extracted. Inline elements still do not split a word (un<b>believ</b>able stays unbelievable).

Tests: added test_adjacent_blocks. It fails without the change ('TitleFirstSecond' != 'Title First Second') and passes with it. Ran the module tests on Odoo 18.0: 4 tests, 0 failed.

text_from_html() joined all text nodes without a separator, so
'<p>First</p><p>Second</p>' gave 'FirstSecond'. This is how the
HTML editor stores content, with no whitespace between blocks.

Add a space around block elements and <br> before extracting the
words. Inline elements still do not split a word.
@oca-cla-bot

oca-cla-bot Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants