when computing <ol><li> numbering, ignore non-<li> previous siblings (#183)

Signed-off-by: chrispy <chrispy@synopsys.com>
This commit is contained in:
Chris Papademetrious
2025-02-04 15:39:32 -05:00
committed by GitHub
parent d0c4b85fd5
commit c52a50e66a
2 changed files with 2 additions and 1 deletions

View File

@@ -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:

View File

@@ -42,6 +42,7 @@ nested_ols = """
def test_ol():
assert md('<ol><li>a</li><li>b</li></ol>') == '\n\n1. a\n2. b\n'
assert md('<ol><!--comment--><li>a</li><span/><li>b</li></ol>') == '\n\n1. a\n2. b\n'
assert md('<ol start="3"><li>a</li><li>b</li></ol>') == '\n\n3. a\n4. b\n'
assert md('foo<ol start="3"><li>a</li><li>b</li></ol>bar') == 'foo\n\n3. a\n4. b\n\nbar'
assert md('<ol start="-1"><li>a</li><li>b</li></ol>') == '\n\n1. a\n2. b\n'