diff --git a/tests/layout/test_list.py b/tests/layout/test_list.py
index 98c7f7936..b0c9daa18 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/tests/resources/tests_ua.css b/tests/resources/tests_ua.css
index c94c83b07..f8d88bdda 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 3074ac860..b10301ff8 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:
@@ -376,6 +375,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: