From c52a50e66a916791f825262f60f96a206287bf30 Mon Sep 17 00:00:00 2001 From: Chris Papademetrious Date: Tue, 4 Feb 2025 15:39:32 -0500 Subject: [PATCH] when computing
  1. numbering, ignore non-
  2. previous siblings (#183) 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 82e8ab5..93a889f 100644 --- a/markdownify/__init__.py +++ b/markdownify/__init__.py @@ -443,7 +443,7 @@ class MarkdownConverter(object): 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 @@ nested_ols = """ 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'