From a92d5912641b6fd26fdfa57af99eba1066e3e84d Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Thu, 10 Sep 2026 12:06:27 +0200 Subject: [PATCH 1/2] =?UTF-8?q?Don=E2=80=99t=20share=20style=20for=20marke?= =?UTF-8?q?rs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/layout/test_list.py | 19 +++++++++++++++++++ weasyprint/formatting_structure/build.py | 1 + 2 files changed, 20 insertions(+) diff --git a/tests/layout/test_list.py b/tests/layout/test_list.py index 98c7f79364..b0c9daa186 100644 --- a/tests/layout/test_list.py +++ b/tests/layout/test_list.py @@ -129,3 +129,22 @@ def test_lists_page_break_margin(): assert ( li.children[0].position_y == li.children[1].children[0].position_y) + + +def test_lists_marker_content(): + # Regression test for #2918. + page, = render_pages(''' + + + ''') + html, = page.children + body, = html.children + ul, = body.children + li, = ul.children + marker, li = li.children + assert marker.children[0].children[0].text == 'a' + assert li.children[0].children[0].text == 'b' diff --git a/weasyprint/formatting_structure/build.py b/weasyprint/formatting_structure/build.py index 3074ac8601..7e768569a6 100644 --- a/weasyprint/formatting_structure/build.py +++ b/weasyprint/formatting_structure/build.py @@ -376,6 +376,7 @@ def marker_to_box(element, state, parent_style, style_for, get_image_from_uri, marker_box = boxes.BlockBox.anonymous_from(box, children) # We can safely edit everything that can't be changed by user style # See https://drafts.csswg.org/css-pseudo-4/#marker-pseudo + marker_box.style = marker_box.style.copy() marker_box.style['position'] = 'absolute' marker_box.is_outside_marker = True else: From 36b851fd065010108c65632c7f4d23f3ea7fee41 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Thu, 10 Sep 2026 12:22:23 +0200 Subject: [PATCH 2/2] Rely on default stylesheet set default marker style This way we avoid style dictionary modification. --- tests/resources/tests_ua.css | 2 ++ weasyprint/formatting_structure/build.py | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/resources/tests_ua.css b/tests/resources/tests_ua.css index c94c83b070..f8d88bdda7 100644 --- a/tests/resources/tests_ua.css +++ b/tests/resources/tests_ua.css @@ -30,6 +30,8 @@ h4 { bookmark-level: 4; bookmark-label: content(text) } h5 { bookmark-level: 5; bookmark-label: content(text) } h6 { bookmark-level: 6; bookmark-label: content(text) } +::marker { white-space: pre } + ::footnote-call { content: counter(footnote) } ::footnote-marker { content: counter(footnote) '.' } ::note-call { content: counter(note) } diff --git a/weasyprint/formatting_structure/build.py b/weasyprint/formatting_structure/build.py index 7e768569a6..b10301ff8c 100644 --- a/weasyprint/formatting_structure/build.py +++ b/weasyprint/formatting_structure/build.py @@ -366,7 +366,6 @@ def marker_to_box(element, state, parent_style, style_for, get_image_from_uri, counter_type = style['list_style_type'] if marker_text := counter_style.render_marker(counter_type, counter_value): box = boxes.TextBox.anonymous_from(box, marker_text) - box.style['white_space'] = 'pre-wrap' children.append(box) if not children: