From 30048b257b1125cbf39e8fbea1da42aec3198aa6 Mon Sep 17 00:00:00 2001 From: Yushuo Sun <135411736+yushuosun@users.noreply.github.com> Date: Sat, 5 Dec 2026 21:53:19 +0800 Subject: [PATCH] Parse ordered-list start as an ASCII decimal value --- markdownify/__init__.py | 5 +++-- tests/test_lists.py | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/markdownify/__init__.py b/markdownify/__init__.py index d946d2c..5cf75d2 100644 --- a/markdownify/__init__.py +++ b/markdownify/__init__.py @@ -635,8 +635,9 @@ def convert_li(self, el, text, parent_tags): # determine list item bullet character to use parent = el.parent if parent is not None and parent.name == 'ol': - if parent.get("start") and str(parent.get("start")).isnumeric(): - start = int(parent.get("start")) + start_value = str(parent.get('start', '')).strip(' \t\n\r\f') + if re.fullmatch(r'[0-9]+', start_value): + start = int(start_value) else: start = 1 bullet = '%s.' % (start + len(el.find_previous_siblings('li'))) diff --git a/tests/test_lists.py b/tests/test_lists.py index e9480ab..fa01684 100644 --- a/tests/test_lists.py +++ b/tests/test_lists.py @@ -87,3 +87,19 @@ def test_bullets(): def test_li_text(): assert md('