Skip to content

Commit ba51bbe

Browse files
authored
Merge pull request #22 from SimonIT/ol-start-attribute
Support the start attribute for ordered lists
2 parents 9f3d497 + ca98892 commit ba51bbe

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

markdownify/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,11 @@ def convert_list(self, el, text):
181181
def convert_li(self, el, text):
182182
parent = el.parent
183183
if parent is not None and parent.name == 'ol':
184-
bullet = '%s.' % (parent.index(el) + 1)
184+
if parent.get("start"):
185+
start = int(parent.get("start"))
186+
else:
187+
start = 1
188+
bullet = '%s.' % (start + parent.index(el))
185189
else:
186190
depth = -1
187191
while el:

tests/test_conversions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ def test_i():
123123

124124
def test_ol():
125125
assert md('<ol><li>a</li><li>b</li></ol>') == '\n1. a\n2. b\n\n'
126+
assert md('<ol start="3"><li>a</li><li>b</li></ol>') == '\n3. a\n4. b\n\n'
126127

127128

128129
def test_p():

0 commit comments

Comments
 (0)