Matt Robinson c578b85699
fix: respect <pre> tag order in partition_html (#1197)
### Summary

Closes #1184. Updates `partition_html` to respect the ordering of
`<pre>` tags in HTML documents.

### Testing

The elements in the following example should be in the correct order.

```python
    from unstructured.partition.html import partition_html

    html_text = """
    <pre>The Big Brown Bear</pre>
    <div>The big brown bear is growling.</div>
    <pre>The big brown bear is sleeping.</pre>
    <div>The Big Blue Bear</div>
    """
    elements = partition_html(text=html_text)
    print("\n\n".join([str(el) for el in elements]))
```
2023-08-25 04:14:48 +00:00

78 lines
2.5 KiB
JSON

[
{
"type": "Title",
"element_id": "56a9f768a0968be676f9addd5ec3032e",
"metadata": {
"data_source": {},
"filetype": "text/html",
"page_number": 1
},
"text": "Downloadify Example"
},
{
"type": "Title",
"element_id": "d551bbfc9477547e4dce6264d8196c7b",
"metadata": {
"data_source": {},
"filetype": "text/html",
"page_number": 1,
"link_urls": [
"http://github.com/dcneiner/Downloadify"
],
"link_texts": [
"Github Project Page"
]
},
"text": "More info available at the Github Project Page"
},
{
"type": "Title",
"element_id": "971b974235a86ca628dcc713d6e2e8d9",
"metadata": {
"data_source": {},
"filetype": "text/html",
"page_number": 1
},
"text": "Filename"
},
{
"type": "NarrativeText",
"element_id": "43f65b1c5bd47774b25c72e2f96de300",
"metadata": {
"data_source": {},
"filetype": "text/html",
"page_number": 1
},
"text": "File Contents\n\nWhatever you put in this text box will be downloaded and saved in the file. If you leave it blank, no file will be downloaded"
},
{
"type": "NarrativeText",
"element_id": "53a4db70c6d40ed5206711ed8a255e03",
"metadata": {
"data_source": {},
"filetype": "text/html",
"page_number": 1
},
"text": "You must have Flash 10 installed to download this file."
},
{
"type": "Title",
"element_id": "839973fba0c850f1729fad098b031203",
"metadata": {
"data_source": {},
"filetype": "text/html",
"page_number": 1
},
"text": "Downloadify Invoke Script For This Page"
},
{
"type": "NarrativeText",
"element_id": "b7db0dffb05f01f3f13d34420b82c261",
"metadata": {
"data_source": {},
"filetype": "text/html",
"page_number": 1
},
"text": "Downloadify.create('downloadify',{\n filename: function(){\n return document.getElementById('filename').value;\n },\n data: function(){ \n return document.getElementById('data').value;\n },\n onComplete: function(){ \n alert('Your File Has Been Saved!'); \n },\n onCancel: function(){ \n alert('You have cancelled the saving of this file.');\n },\n onError: function(){ \n alert('You must put something in the File Contents or there will be nothing to save!'); \n },\n swf: 'media/downloadify.swf',\n downloadImage: 'images/download.png',\n width: 100,\n height: 30,\n transparent: true,\n append: false\n});"
}
]