-
Notifications
You must be signed in to change notification settings - Fork 782
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
122 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from unstructured.partition.html import partition_html | ||
|
||
|
||
def test_alternative_image_text_can_be_included(): | ||
# language=HTML | ||
html = """ | ||
<div class="Page"> | ||
<img src="my-logo.png" alt="ALT TEXT Logo"/> | ||
</div> | ||
""" | ||
_, image_to_text_alt_mode = partition_html( | ||
text=html, | ||
image_alt_mode="to_text", | ||
html_parser_version="v2", | ||
) | ||
assert "ALT TEXT Logo" in image_to_text_alt_mode.text | ||
|
||
_, image_none_alt_mode = partition_html( | ||
text=html, | ||
image_alt_mode=None, | ||
html_parser_version="v2", | ||
) | ||
assert "ALT TEXT Logo" not in image_none_alt_mode.text | ||
|
||
|
||
def test_alternative_image_text_can_be_included_when_nested_in_paragraph(): | ||
# language=HTML | ||
html = """ | ||
<div class="Page"> | ||
<p class="Paragraph"> | ||
<img src="my-logo.png" alt="ALT TEXT Logo"/> | ||
</p> | ||
</div> | ||
""" | ||
_, paragraph_to_text_alt_mode = partition_html( | ||
text=html, | ||
image_alt_mode="to_text", | ||
html_parser_version="v2", | ||
) | ||
assert "ALT TEXT Logo" in paragraph_to_text_alt_mode.text | ||
|
||
_, paragraph_none_alt_mode = partition_html( | ||
text=html, | ||
image_alt_mode=None, | ||
html_parser_version="v2", | ||
) | ||
assert "ALT TEXT Logo" not in paragraph_none_alt_mode.text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.16.6" # pragma: no cover | ||
__version__ = "0.16.7-dev0" # pragma: no cover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters