From 8e0218424d791e79f22fdd02087322ee6951ba5a Mon Sep 17 00:00:00 2001 From: chrispy Date: Sat, 1 Feb 2025 09:00:43 -0500 Subject: [PATCH] when computing
  1. numbering, ignore non-
  2. previous siblings Signed-off-by: chrispy --- markdownify/__init__.py | 2 +- tests/test_lists.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/markdownify/__init__.py b/markdownify/__init__.py index 7d14fe7..8f72773 100644 --- a/markdownify/__init__.py +++ b/markdownify/__init__.py @@ -444,7 +444,7 @@ def convert_li(self, el, text, convert_as_inline): start = int(parent.get("start")) else: start = 1 - bullet = '%s.' % (start + parent.index(el)) + bullet = '%s.' % (start + len(el.find_previous_siblings('li'))) else: depth = -1 while el: diff --git a/tests/test_lists.py b/tests/test_lists.py index 6b320ca..e9480ab 100644 --- a/tests/test_lists.py +++ b/tests/test_lists.py @@ -42,6 +42,7 @@ def test_ol(): assert md('
    1. a
    2. b
    ') == '\n\n1. a\n2. b\n' + assert md('
    1. a
    2. b
    ') == '\n\n1. a\n2. b\n' assert md('
    1. a
    2. b
    ') == '\n\n3. a\n4. b\n' assert md('foo
    1. a
    2. b
    bar') == 'foo\n\n3. a\n4. b\n\nbar' assert md('
    1. a
    2. b
    ') == '\n\n1. a\n2. b\n'