MiXiBo 0506aff788
add support for start_index in html links extraction (#2600)
add support for start_index in html links extraction (closes #2625)

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


html_text = """<html>
        <p>Hello there I am a <a href="/link">very important link!</a></p>
        <p>Here is a list of my favorite things</p>
        <ul>
            <li><a href="https://en.wikipedia.org/wiki/Parrot">Parrots</a></li>
            <li>Dogs</li>
        </ul>
        <a href="/loner">A lone link!</a>
    </html>"""

elements = partition_html(text=html_text)
print(elements_to_json(elements))
```

---------

Co-authored-by: Michael Niestroj <michael.niestroj@unblu.com>
Co-authored-by: christinestraub <christinemstraub@gmail.com>
Co-authored-by: ryannikolaidis <1208590+ryannikolaidis@users.noreply.github.com>
Co-authored-by: christinestraub <christinestraub@users.noreply.github.com>
Co-authored-by: Ronny H <138828701+ron-unstructured@users.noreply.github.com>
2024-04-12 06:14:20 +00:00

179 lines
5.7 KiB
JSON

[
{
"element_id": "56a9f768a0968be676f9addd5ec3032e",
"metadata": {
"data_source": {
"date_modified": "2010-01-23T23:18:40",
"record_locator": {
"file_path": "test.html",
"repo_path": "dcneiner/Downloadify"
},
"url": "https://raw.githubusercontent.com/dcneiner/Downloadify/master/test.html",
"version": "W/\"c63c8fc21d46d44de85a14a3ed4baec0348ce344\""
},
"filetype": "text/html",
"languages": [
"eng"
],
"page_number": 1
},
"text": "Downloadify Example",
"type": "Title"
},
{
"element_id": "d551bbfc9477547e4dce6264d8196c7b",
"metadata": {
"data_source": {
"date_modified": "2010-01-23T23:18:40",
"record_locator": {
"file_path": "test.html",
"repo_path": "dcneiner/Downloadify"
},
"url": "https://raw.githubusercontent.com/dcneiner/Downloadify/master/test.html",
"version": "W/\"c63c8fc21d46d44de85a14a3ed4baec0348ce344\""
},
"filetype": "text/html",
"languages": [
"eng"
],
"link_start_indexes": [
27
],
"link_texts": [
"Github Project Page"
],
"link_urls": [
"http://github.com/dcneiner/Downloadify"
],
"page_number": 1
},
"text": "More info available at the Github Project Page",
"type": "Title"
},
{
"element_id": "971b974235a86ca628dcc713d6e2e8d9",
"metadata": {
"data_source": {
"date_modified": "2010-01-23T23:18:40",
"record_locator": {
"file_path": "test.html",
"repo_path": "dcneiner/Downloadify"
},
"url": "https://raw.githubusercontent.com/dcneiner/Downloadify/master/test.html",
"version": "W/\"c63c8fc21d46d44de85a14a3ed4baec0348ce344\""
},
"filetype": "text/html",
"languages": [
"eng"
],
"page_number": 1
},
"text": "Filename",
"type": "Title"
},
{
"element_id": "4112a488690bdbc1d39d5b78068eae9f",
"metadata": {
"data_source": {
"date_modified": "2010-01-23T23:18:40",
"record_locator": {
"file_path": "test.html",
"repo_path": "dcneiner/Downloadify"
},
"url": "https://raw.githubusercontent.com/dcneiner/Downloadify/master/test.html",
"version": "W/\"c63c8fc21d46d44de85a14a3ed4baec0348ce344\""
},
"filetype": "text/html",
"languages": [
"eng"
],
"page_number": 1
},
"text": "File Contents",
"type": "Title"
},
{
"element_id": "f89c9cf63bd2e72f560ee043d942a1e7",
"metadata": {
"data_source": {
"date_modified": "2010-01-23T23:18:40",
"record_locator": {
"file_path": "test.html",
"repo_path": "dcneiner/Downloadify"
},
"url": "https://raw.githubusercontent.com/dcneiner/Downloadify/master/test.html",
"version": "W/\"c63c8fc21d46d44de85a14a3ed4baec0348ce344\""
},
"filetype": "text/html",
"languages": [
"eng"
],
"page_number": 1
},
"text": "Whatever 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": {
"date_modified": "2010-01-23T23:18:40",
"record_locator": {
"file_path": "test.html",
"repo_path": "dcneiner/Downloadify"
},
"url": "https://raw.githubusercontent.com/dcneiner/Downloadify/master/test.html",
"version": "W/\"c63c8fc21d46d44de85a14a3ed4baec0348ce344\""
},
"filetype": "text/html",
"languages": [
"eng"
],
"page_number": 1
},
"text": "You must have Flash 10 installed to download this file.",
"type": "NarrativeText"
},
{
"element_id": "839973fba0c850f1729fad098b031203",
"metadata": {
"data_source": {
"date_modified": "2010-01-23T23:18:40",
"record_locator": {
"file_path": "test.html",
"repo_path": "dcneiner/Downloadify"
},
"url": "https://raw.githubusercontent.com/dcneiner/Downloadify/master/test.html",
"version": "W/\"c63c8fc21d46d44de85a14a3ed4baec0348ce344\""
},
"filetype": "text/html",
"languages": [
"eng"
],
"page_number": 1
},
"text": "Downloadify Invoke Script For This Page",
"type": "Title"
},
{
"element_id": "b7db0dffb05f01f3f13d34420b82c261",
"metadata": {
"data_source": {
"date_modified": "2010-01-23T23:18:40",
"record_locator": {
"file_path": "test.html",
"repo_path": "dcneiner/Downloadify"
},
"url": "https://raw.githubusercontent.com/dcneiner/Downloadify/master/test.html",
"version": "W/\"c63c8fc21d46d44de85a14a3ed4baec0348ce344\""
},
"filetype": "text/html",
"languages": [
"eng"
],
"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});",
"type": "NarrativeText"
}
]