Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

chrispy-snps
Copy link
Collaborator

Currently, numbering for <li> items inside <ol> count all previous siblings when computing the number:

import markdownify

html = """
<ol>
  <!--comment-->
  <li>a</li>
  <div/>
  <li>b</li>
</ol>
"""

print(markdownify.MarkdownConverter().convert(html))
# 2. a
# 4. b

This pull request updates the code to consider only preceding <li> elements:

print(markdownify.MarkdownConverter().convert(html))
# 1. a
# 2. b

A unit test is added to check this case.

@chrispy-snps chrispy-snps requested a review from AlexVonB February 1, 2025 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant