mirror of
https://github.com/Kozea/WeasyPrint.git
synced 2024-09-11 20:47:56 +03:00
Filter args with value None before calling html5lib.parse
This commit is contained in:
parent
563545e7cf
commit
92948eb2e5
@ -162,10 +162,15 @@ class HTML:
|
||||
if isinstance(source, str):
|
||||
result = html5lib.parse(source, namespaceHTMLElements=False)
|
||||
else:
|
||||
result = html5lib.parse(
|
||||
source, override_encoding=encoding,
|
||||
transport_encoding=protocol_encoding,
|
||||
namespaceHTMLElements=False)
|
||||
potentially_undefined_kwargs = {
|
||||
'namespaceHTMLElements': False,
|
||||
'transport_encoding': protocol_encoding,
|
||||
'override_encoding': encoding,
|
||||
}
|
||||
|
||||
filtered_kwargs = {k: v for k, v in potentially_undefined_kwargs.items() if v is not None}
|
||||
|
||||
result = html5lib.parse(source, **filtered_kwargs)
|
||||
self.base_url = _find_base_url(result, base_url)
|
||||
self.url_fetcher = url_fetcher
|
||||
self.media_type = media_type
|
||||
|
Loading…
Reference in New Issue
Block a user