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 2 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,4 +1,4 @@
## 0.5.0
## 0.5.0-dev1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add this under 0.5.1-dev1 and add it as a new entry above 0.5.0?


### Enhancements

Expand All @@ -14,6 +14,7 @@ instantiating a class or running a function
* Fix `process_document` file cleaning on failure
* Fixes an error introduced in the metadata tracking commit that caused `NarrativeText`
and `FigureCaption` elements to be represented as `Text` in HTML documents.
* Fixes an error causing JavaScript to appear in the output of `partition_html` sometimes.

## 0.4.16

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.0" # pragma: no cover
__version__ = "0.5.0-dev1" # pragma: no cover
6 changes: 3 additions & 3 deletions unstructured/documents/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ 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
for item in tag_elem.iter():
if item.text and item.tag != "script":
text += item.text

if tag_elem.tail:
text = text + tag_elem.tail
Expand Down