Skip to content

bug(html): <br/> element breaks paragraph/document-element #3227

Closed

Description

@scanny

A <br/> element within a block item (e.g. <div>, <p>, etc. causes the element to be closed and a new one started, mid-paragraph.

According to the HTML Standard, a <br/> element is a phrasing (inline) element and indicates a line-break but does not divide the current block item in two.

To Reproduce

from unstructured.partition.html import partition_html
from unstructured.staging.base import elements_to_json

html_text = """
<p>
  Too old to begin<br/>
  training of young Skywalker.<br/>
  But teach him, I must.
</p>
"""
elements = partition_html(text=html_text)
print(f"{elements_to_json(elements, indent=2)}")

Expected:

[
  {
    "element_id": "44c358a19a9d7b9a1c3c9ac999b5bf93",
    "metadata": {
      "filetype": "text/html",
      "languages": ["eng"]
    },
    "text": "Too old to begin training of young Skywalker. But teach him, I must.",
    "type": "NarrativeText"
  }
]

Actual:

[
  {
    "element_id": "1db998dab696f74fde0d739e735f2000",
    "metadata": {
      "filetype": "text/html",
      "languages": ["eng"]
    },
    "text": "Too old to begin",
    "type": "NarrativeText"
  },
  {
    "element_id": "a4353319423f2724bc3f216847bf08fb",
    "metadata": {
      "category_depth": 0,
      "filetype": "text/html",
      "languages": ["eng"]
    },
    "text": "training of young Skywalker.",
    "type": "Title"
  },
  {
    "element_id": "1227d247a181c4f0aefb7992a1ee7ac4",
    "metadata": {
      "filetype": "text/html",
      "languages": ["eng"],
      "parent_id": "a4353319423f2724bc3f216847bf08fb"
    },
    "text": "But teach him, I must.",
    "type": "NarrativeText"
  }
]

Additional context
Fixed by #3218. Recorded here to explain ingest test output changes and to inform CHANGELOG.

Activity

  1. added
    bug
    on Jun 18, 2024
  2. self-assigned this
    on Jun 18, 2024
  3. added a commit that references this issue on Jul 11, 2024
    c27e0d0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bughtml

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions