Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions test_unstructured/partition/html/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1595,6 +1595,15 @@ def it_is_used_for_elements_whose_content_is_not_rendered_as_text(self, html_tex
assert isinstance(div[0], RemovedPhrasing)
assert [e.text for e in div.iter_elements()] == ["Before after."]

def and_it_is_used_for_ruby_text_so_it_is_not_glued_to_the_base_text(self):
html = (
"<p>首都は<ruby>東京<rp>(</rp><rt>とうきょう</rt><rp>)</rp></ruby>です。"
"<ruby>漢<rt>かん</rt>字<rt>じ</rt></ruby></p>"
)
p = etree.fromstring(html, html_parser).xpath(".//p")[0]

assert [e.text for e in p.iter_elements()] == ["首都は東京です。漢字"]

def and_it_is_used_for_head_which_is_only_reached_when_there_is_no_body(self):
root = etree.fromstring("<html><head><foobar>Metadata</foobar></head></html>", html_parser)

Expand Down
2 changes: 2 additions & 0 deletions unstructured/partition/html/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,8 @@ def derive_element_type_from_text(text: str) -> type[Text] | None:
"noembed": RemovedPhrasing, # -- obsolete; fallback content for `<embed>` --
"noframes": RemovedPhrasing, # -- obsolete; fallback content for frames --
"object": RemovedPhrasing, # -- content is fallback for when the object can't be shown --
"rp": RemovedPhrasing, # -- parentheses shown around `<rt>` only without ruby support --
"rt": RemovedPhrasing, # -- ruby text, a reading aid like furigana for the base text --
"select": RemovedPhrasing, # -- form control; its option list is not document text --
"svg": RemovedPhrasing, # -- graphics; `<title>` and `<desc>` inside it are metadata --
"textarea": RemovedPhrasing, # -- form control; its content is the editable value --
Expand Down
Loading