Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion markdownify/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ def convert_li(self, el, text, parent_tags):
# determine list item bullet character to use
parent = el.parent
if parent is not None and parent.name == 'ol':
if parent.get("start") and str(parent.get("start")).isnumeric():
if parent.get("start") and str(parent.get("start")).isdecimal():
start = int(parent.get("start"))
else:
start = 1
Expand Down
12 changes: 12 additions & 0 deletions tests/test_lists.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pytest

from .utils import md


Expand Down Expand Up @@ -51,6 +53,16 @@ def test_ol():
assert md('<ol start="1234"><li><p>first para</p><p>second para</p></li><li><p>third para</p><p>fourth para</p></li></ol>') == '\n\n1234. first para\n\n second para\n1235. third para\n\n fourth para\n'


@pytest.mark.parametrize('start', ['\u00b2', '\u2163', '\u00bd', '\u56db'])
def test_ol_non_decimal_numeric_start(start):
assert md('<ol start="%s"><li>a</li><li>b</li></ol>' % start) == '\n\n1. a\n2. b\n'


@pytest.mark.parametrize('start', ['3', '\u0663', '\uff13'])
def test_ol_decimal_start(start):
assert md('<ol start="%s"><li>a</li><li>b</li></ol>' % start) == '\n\n3. a\n4. b\n'


def test_nested_ols():
assert md(nested_ols) == '\n\n1. 1\n 1. a\n 1. I\n 2. II\n 3. III\n 2. b\n 3. c\n2. 2\n3. 3\n'

Expand Down