mirror of
https://github.com/Kozea/WeasyPrint.git
synced 2024-09-11 20:47:56 +03:00
Clean code handling keyword args for html5lib.parse
This commit is contained in:
parent
92948eb2e5
commit
f58fd3b42b
@ -162,15 +162,12 @@ class HTML:
|
||||
if isinstance(source, str):
|
||||
result = html5lib.parse(source, namespaceHTMLElements=False)
|
||||
else:
|
||||
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)
|
||||
kwargs = {'namespaceHTMLElements': 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)
|
||||
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