Commit 0157bb6
committed
fix: drop processing instructions in HTML parser
partition_html() crashed with 'lxml.etree._ProcessingInstruction object
has no attribute is_phrasing' when the document contained a processing
instruction such as '<?xml ...?>'. The HTML parser's element-class lookup
only maps real elements, so a processing instruction reaches the tree as a
plain lxml _ProcessingInstruction node without the parser's custom
interface, then crashes the phrasing/flow iteration.
Pass remove_pis=True to the HTMLParser so processing instructions are
stripped during parsing, mirroring the existing remove_comments=True. They
carry no rendered text, so dropping them matches browser behavior.
Fixes #43581 parent 7c8f675 commit 0157bb6
4 files changed
Lines changed: 20 additions & 2 deletions
File tree
- test_unstructured/partition/html
- unstructured
- partition/html
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
1 | 7 | | |
2 | 8 | | |
3 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
206 | 215 | | |
207 | 216 | | |
208 | 217 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
945 | 945 | | |
946 | 946 | | |
947 | 947 | | |
948 | | - | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
949 | 952 | | |
950 | 953 | | |
951 | 954 | | |
| |||
0 commit comments