Fix br tail text handling in HTML tables#4351
Open
dsolankii wants to merge 1 commit into
Open
Conversation
Author
|
@cragwolfe Would you please review? |
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.
Fixes #3899.
Summary
This PR fixes text loss when normalizing HTML tables that contain
<br/>tags inside table cells.HtmlTable.from_html_text()previously removed all element tail text during normalization. For<br/>elements, the text after the tag is stored as tail text, so content after line breaks was dropped from the normalized HTML output.Problem
Given an HTML table cell like:
This is 1st line.<br/>2nd line.<br/>3rd line.the normalized table output preserved the
<br/>tags but dropped the text after them, resulting in loss of2nd line.and3rd line..Solution
This change preserves normalized tail text for
<br/>elements while continuing to remove tail text for other elements.This keeps the existing cleanup behavior for table normalization but avoids dropping valid content that follows line break tags.
Changes
<br/>elements inHtmlTable.from_html_text().brelements.<br/>tags in HTML table cells.How to test
Run the targeted regression test:
Expected result:
Validation
I reproduced the issue locally before applying the fix.
Before the fix, this input lost the text after
<br/>tags:This is 1st line.<br/>2nd line.<br/>3rd line.After the fix, the normalized table preserves all lines:
This is 1st line.<br/>2nd line.<br/>3rd line.The targeted regression test passes locally.