Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove JavaScript from HTML reader output #313

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
## 0.5.1-dev1
## 0.5.1-dev2

### Enhancements

### Features

### Fixes

* Fixes an error causing JavaScript to appear in the output of `partition_html` sometimes.
* Fix several issues with the `requires_dependencies` decorator, including the error message
and how it was used.

Expand Down
2 changes: 1 addition & 1 deletion unstructured/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.5.1-dev1" # pragma: no cover
__version__ = "0.5.1-dev2" # pragma: no cover
11 changes: 5 additions & 6 deletions unstructured/documents/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,11 @@ def is_narrative_tag(text: str, tag: str) -> bool:
def _construct_text(tag_elem: etree.Element) -> str:
"""Extracts text from a text tag element."""
text = ""
for item in tag_elem.itertext():
if item:
text += item

if tag_elem.tail:
text = text + tag_elem.tail
for item in tag_elem.iter():
if item.text and item.tag != "script":
text += item.text
if item.tail:
text += item.tail

text = replace_unicode_quotes(text)
return text.strip()
Expand Down