1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-10-04 16:07:57 +03:00

Fix text-indent at the beginning of the page

Fix #706.
This commit is contained in:
Guillaume Ayoub 2018-10-26 18:49:40 +02:00
parent 6b24c25d5a
commit b0944e718a
2 changed files with 34 additions and 2 deletions

View File

@ -45,8 +45,11 @@ def iter_line_boxes(context, box, position_y, skip_stack, containing_block,
"""
resolve_percentages(box, containing_block)
# TODO: that's wrong, see https://github.com/Kozea/WeasyPrint/issues/679
resolve_one_percentage(box, 'text_indent', containing_block.width)
if skip_stack is None:
# TODO: wrong, see https://github.com/Kozea/WeasyPrint/issues/679
resolve_one_percentage(box, 'text_indent', containing_block.width)
else:
box.text_indent = 0
while 1:
line, resume_at = get_next_linebox(
context, box, position_y, skip_stack, containing_block,

View File

@ -388,6 +388,35 @@ def test_text_indent(indent):
assert text_3.position_x == 10 # No indent
@pytest.mark.parametrize('indent', ('12px', '6%'))
@assert_no_logs
def test_text_indent_multipage(indent):
# Test regression: https://github.com/Kozea/WeasyPrint/issues/706
pages = render_pages('''
<style>
@page { size: 220px 1.5em; margin: 0 }
body { margin: 10px; text-indent: %(indent)s }
</style>
<p>Some text that is long enough that it take at least three line,
but maybe more.
''' % {'indent': indent})
page = pages.pop(0)
html, = page.children
body, = html.children
paragraph, = body.children
line, = paragraph.children
text, = line.children
assert text.position_x == 22 # 10px margin-left + 12px indent
page = pages.pop(0)
html, = page.children
body, = html.children
paragraph, = body.children
line, = paragraph.children
text, = line.children
assert text.position_x == 10 # No indent
@assert_no_logs
def test_hyphenate_character_1():
page, = render_pages(