Repository navigation
[18.0][FIX] html_text: keep words of adjacent blocks apart - #3871
Open
GebleaAlex wants to merge 1 commit into
Open
GebleaAlex wants to merge 1 commit into
GebleaAlex wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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>->abThe 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>ablestaysunbelievable).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.