Use tinyhtml5 instead of html5lib
This commit is contained in:
@@ -13,7 +13,7 @@ WeasyPrint |version| depends on:
|
||||
* Pango_ ≥ 1.44.0
|
||||
* pydyf_ ≥ 0.10.0
|
||||
* CFFI_ ≥ 0.6
|
||||
* html5lib_ ≥ 1.1
|
||||
* tinyhtml5_ ≥ 2.0.0b1
|
||||
* tinycss2_ ≥ 1.3.0
|
||||
* cssselect2_ ≥ 0.1
|
||||
* Pyphen_ ≥ 0.9.1
|
||||
@@ -23,8 +23,8 @@ WeasyPrint |version| depends on:
|
||||
.. _Python: https://www.python.org/
|
||||
.. _Pango: https://pango.gnome.org/
|
||||
.. _CFFI: https://cffi.readthedocs.io/
|
||||
.. _html5lib: https://html5lib.readthedocs.io/
|
||||
.. _pydyf: https://doc.courtbouillon.org/pydyf/
|
||||
.. _tinyhtml5: https://doc.courtbouillon.org/tinyhtml5/
|
||||
.. _tinycss2: https://doc.courtbouillon.org/tinycss2/
|
||||
.. _cssselect2: https://doc.courtbouillon.org/cssselect2/
|
||||
.. _Pyphen: https://pyphen.org/
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ license = {file = 'LICENSE'}
|
||||
dependencies = [
|
||||
'pydyf >=0.11.0,<0.12',
|
||||
'cffi >=0.6,<2',
|
||||
'html5lib >=1.1,<2',
|
||||
'tinyhtml5 >=2.0.0b1,<3',
|
||||
'tinycss2 >=1.3.0,<2',
|
||||
'cssselect2 >=0.1,<0.8',
|
||||
'Pyphen >=0.9.1,<0.16',
|
||||
|
||||
@@ -12,8 +12,8 @@ from pathlib import Path
|
||||
from urllib.parse import urljoin
|
||||
|
||||
import cssselect2
|
||||
import html5lib
|
||||
import tinycss2
|
||||
import tinyhtml5
|
||||
|
||||
VERSION = __version__ = '62.3'
|
||||
|
||||
@@ -111,7 +111,7 @@ def _find_base_url(html_document, fallback_base_url):
|
||||
|
||||
|
||||
class HTML:
|
||||
"""HTML document parsed by html5lib.
|
||||
"""HTML document parsed by tinyhtml5.
|
||||
|
||||
You can just create an instance with a positional argument:
|
||||
``doc = HTML(something)``
|
||||
@@ -169,14 +169,14 @@ class HTML:
|
||||
guess, filename, url, file_obj, string, base_url, url_fetcher)
|
||||
with result as (source_type, source, base_url, protocol_encoding):
|
||||
if isinstance(source, str):
|
||||
result = html5lib.parse(source, namespaceHTMLElements=False)
|
||||
result = tinyhtml5.parse(source, namespace_html_elements=False)
|
||||
else:
|
||||
kwargs = {'namespaceHTMLElements': False}
|
||||
kwargs = {'namespace_html_elements': False}
|
||||
if protocol_encoding is not None:
|
||||
kwargs['transport_encoding'] = protocol_encoding
|
||||
if encoding is not None:
|
||||
kwargs['override_encoding'] = encoding
|
||||
result = html5lib.parse(source, **kwargs)
|
||||
result = tinyhtml5.parse(source, **kwargs)
|
||||
self.base_url = _find_base_url(result, base_url)
|
||||
self.url_fetcher = url_fetcher
|
||||
self.media_type = media_type
|
||||
|
||||
+2
-2
@@ -45,8 +45,8 @@ class StreamingGzipFile(GzipFile):
|
||||
GzipFile.close(self)
|
||||
self.fileobj_to_close.close()
|
||||
|
||||
# Inform html5lib to not rely on these:
|
||||
seek = tell = None
|
||||
def seekable(self):
|
||||
return False
|
||||
|
||||
|
||||
def iri_to_uri(url):
|
||||
|
||||
Reference in New Issue
Block a user