Repository navigation
fix(html): leave ruby text out of the paragraph text - #4837
Open
gagan-baghel wants to merge 1 commit into
Open
gagan-baghel wants to merge 1 commit into
gagan-baghel wants to merge 1 commit into
Conversation
<rt> and <rp> had no element class, so they were transparent and their text was glued to the base text: "東京<rt>とうきょう</rt>" became "東京とうきょう". Skip them like other content that is not shown as body text.
This branch has not been deployed
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.
Summary
partition_html()glues ruby text to the base text it annotates. Japanese pages use ruby for furigana, and Chinese pages use it for pinyin:<rt>and<rp>had no element class, soDefaultElementtreated them as transparent. Their text was then merged into the sentence, which corrupts search, embeddings and chunk text for東京. This change maps both toRemovedPhrasing, like other content that isn't rendered as body text. The tail after each tag is kept.<rp>holds the fallback parentheses that browsers hide when they support ruby.Validation
and_it_is_used_for_ruby_text_so_it_is_not_glued_to_the_base_texttoDescribeRemovedPhrasing. It covers<rp>and two ruby pairs in one element. It fails onmainand passes with this change.pytest test_unstructured/partition/html test_unstructured/documents: 667 passed.ruff checkandruff format --checkpass on the changed files.Checklist
bug): I can't add labels, so please apply it.