Skip to content

Commit c52a50e

Browse files
authored
when computing <ol><li> numbering, ignore non-<li> previous siblings (#183)
Signed-off-by: chrispy <[email protected]>
1 parent d0c4b85 commit c52a50e

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Diff for: markdownify/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ def convert_li(self, el, text, convert_as_inline):
443443
start = int(parent.get("start"))
444444
else:
445445
start = 1
446-
bullet = '%s.' % (start + parent.index(el))
446+
bullet = '%s.' % (start + len(el.find_previous_siblings('li')))
447447
else:
448448
depth = -1
449449
while el:

Diff for: tests/test_lists.py

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242

4343
def test_ol():
4444
assert md('<ol><li>a</li><li>b</li></ol>') == '\n\n1. a\n2. b\n'
45+
assert md('<ol><!--comment--><li>a</li><span/><li>b</li></ol>') == '\n\n1. a\n2. b\n'
4546
assert md('<ol start="3"><li>a</li><li>b</li></ol>') == '\n\n3. a\n4. b\n'
4647
assert md('foo<ol start="3"><li>a</li><li>b</li></ol>bar') == 'foo\n\n3. a\n4. b\n\nbar'
4748
assert md('<ol start="-1"><li>a</li><li>b</li></ol>') == '\n\n1. a\n2. b\n'

0 commit comments

Comments
 (0)