mirror of
https://github.com/Kozea/WeasyPrint.git
synced 2024-10-04 07:57:52 +03:00
Remove monkey patches about float
This commit is contained in:
parent
6449ee4cbf
commit
d4ccf3db63
@ -79,15 +79,6 @@ def to_lists(box_tree):
|
||||
return serialize(unwrap_html_body(box_tree))
|
||||
|
||||
|
||||
def validate_float(
|
||||
real_non_shorthand, base_url, name, values, required=False):
|
||||
"""Fake validator for ``float``."""
|
||||
value = values[0].value
|
||||
if name == 'float' and value == 'left':
|
||||
return [(name, value)]
|
||||
return real_non_shorthand(base_url, name, values, required)
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def monkeypatch_validation(replacement):
|
||||
"""Create a context manager patching the validation mechanism.
|
||||
@ -112,12 +103,11 @@ def monkeypatch_validation(replacement):
|
||||
|
||||
def parse(html_content):
|
||||
"""Parse some HTML, apply stylesheets and transform to boxes."""
|
||||
with monkeypatch_validation(validate_float):
|
||||
document = TestPNGDocument(html_content,
|
||||
# Dummy filename, but in the right directory.
|
||||
base_url=resource_filename('<test>'))
|
||||
box, = build.dom_to_box(document, document.dom)
|
||||
return box
|
||||
document = TestPNGDocument(html_content,
|
||||
# Dummy filename, but in the right directory.
|
||||
base_url=resource_filename('<test>'))
|
||||
box, = build.dom_to_box(document, document.dom)
|
||||
return box
|
||||
|
||||
|
||||
def parse_all(html_content, base_url=resource_filename('<test>')):
|
||||
|
@ -15,7 +15,7 @@ from __future__ import division, unicode_literals
|
||||
|
||||
from .testing_utils import (
|
||||
TestPNGDocument, resource_filename, FONTS, assert_no_logs, capture_logs)
|
||||
from .test_boxes import monkeypatch_validation, validate_float
|
||||
from .test_boxes import monkeypatch_validation
|
||||
from ..formatting_structure import boxes
|
||||
from ..layout.inlines import split_inline_box
|
||||
from ..layout.percentages import resolve_percentages
|
||||
@ -39,14 +39,12 @@ def parse_without_layout(html_content):
|
||||
|
||||
def parse(html_content, return_document=False):
|
||||
"""Parse some HTML, apply stylesheets, transform to boxes and lay out."""
|
||||
# TODO: remove this patching when floats are validated
|
||||
with monkeypatch_validation(validate_float):
|
||||
document = TestPNGDocument(html_content,
|
||||
base_url=resource_filename('<inline HTML>'))
|
||||
if return_document:
|
||||
return document
|
||||
else:
|
||||
return document.pages
|
||||
document = TestPNGDocument(html_content,
|
||||
base_url=resource_filename('<inline HTML>'))
|
||||
if return_document:
|
||||
return document
|
||||
else:
|
||||
return document.pages
|
||||
|
||||
|
||||
@assert_no_logs
|
||||
|
Loading…
Reference in New Issue
Block a user