diff --git a/tests/test_text.py b/tests/test_text.py index 835ab6d193..78302f5083 100644 --- a/tests/test_text.py +++ b/tests/test_text.py @@ -950,8 +950,8 @@ def test_overflow_wrap_2(wrap, text, body_width, expected_width): @pytest.mark.parametrize('wrap, text, body_width, expected_width', ( ('anywhere', 'aaaaaa', 10, 20), ('anywhere', 'aaaaaa', 40, 40), - # ('break-word', 'abcdef', 40, 120), - # ('normal', 'abcdef', 40, 120), + ('break-word', 'aaaaaa', 40, 120), + ('normal', 'abcdef', 40, 120), )) def test_overflow_wrap_trailing_space(wrap, text, body_width, expected_width): page, = render_pages(''' diff --git a/weasyprint/layout/preferred.py b/weasyprint/layout/preferred.py index 7623b94d70..124d1c2424 100644 --- a/weasyprint/layout/preferred.py +++ b/weasyprint/layout/preferred.py @@ -198,19 +198,16 @@ def inline_min_content_width(context, box, outer=True, skip_stack=None, widths = inline_line_widths( context, box, outer, is_line_start, minimum=True, skip_stack=skip_stack, first_line=first_line) - - if first_line: - widths = [next(widths)] - else: - widths = list(widths) - widths[-1] -= trailing_whitespace_size(context, box) - return adjust(box, outer, max(widths)) + width = next(widths) if first_line else max(widths) + return adjust(box, outer, width) def inline_max_content_width(context, box, outer=True, is_line_start=False): """Return the max-content width for an ``InlineBox``.""" widths = list( inline_line_widths(context, box, outer, is_line_start, minimum=False)) + # Remove trailing space, as split_first_line keeps trailing spaces when + # max_width is not set. widths[-1] -= trailing_whitespace_size(context, box) return adjust(box, outer, max(widths))