mirror of
https://github.com/Unstructured-IO/unstructured.git
synced 2025-07-13 03:55:55 +00:00

**Summary** Extract as much mechanical refactoring from the HTML parser change-over into the PR as possible. This leaves the next PR focused on installing the new parser and the ingest-test impact. **Reviewers:** Commits are well groomed and reviewing commit-by-commit is probably easier. **Additional Context** This PR introduces the rewritten HTML parser. Its general design is recursive, consistent with the recursive structure of HTML (tree of elements). It also adds the unit tests for that parser but it does not _install_ the parser. So the behavior of `partition_html()` is unchanged by this PR. The next PR in this series will do that and handle the ingest and other unit test changes required to reflect the dozen or so bug-fixes the new parser provides.
42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from ._classlookup import ElementClassLookup
|
|
|
|
class HTMLParser:
|
|
def __init__(
|
|
self,
|
|
*,
|
|
encoding: str | None = None,
|
|
remove_blank_text: bool = False,
|
|
remove_comments: bool = False,
|
|
remove_pis: bool = False,
|
|
strip_cdata: bool = True,
|
|
no_network: bool = True,
|
|
recover: bool = True,
|
|
compact: bool = True,
|
|
default_doctype: bool = True,
|
|
collect_ids: bool = True,
|
|
huge_tree: bool = False,
|
|
) -> None: ...
|
|
def set_element_class_lookup(self, lookup: ElementClassLookup | None = None) -> None: ...
|
|
|
|
class XMLParser:
|
|
def __init__(
|
|
self,
|
|
*,
|
|
encoding: str | None = None,
|
|
attribute_defaults: bool = False,
|
|
dtd_validation: bool = False,
|
|
load_dtd: bool = False,
|
|
no_network: bool = True,
|
|
ns_clean: bool = False,
|
|
recover: bool = False,
|
|
huge_tree: bool = False,
|
|
remove_blank_text: bool = False,
|
|
remove_comments: bool = False,
|
|
remove_pis: bool = False,
|
|
strip_cdata: bool = True,
|
|
collect_ids: bool = True,
|
|
compact: bool = True,
|
|
) -> None: ...
|