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

Space before <ol> or <ul> element incorrectly indents the first list item #144

Open
chrispy-snps opened this issue Sep 7, 2024 · 1 comment

Comments

@chrispy-snps
Copy link
Collaborator

If an <ol> or <ul> element follows another element on the same line, and there is a space before it:

from markdownify import markdownify as md

html = """
<p>Follow these steps:</p> <ol>
   <li><p>Do this.</p></li>
   <li><p>Do that.</p></li>
</ol>"""

print(md(html))

then that space incorrectly indents the first list item:

Follow these steps:

 1. Do this.
2. Do that.

As a workaround, we preprocess our Beautiful Soup object as follows:

for n in node_markdown.find_all(["ol", "ul"]):
    n.insert_before("\n")
@jsm28
Copy link
Contributor

jsm28 commented Sep 9, 2024

Should be fixed by my PR #120.

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

No branches or pull requests

2 participants