matthewwithanm/python-markdownify

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

chrispy-snps opened this issue · 2 comments

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 commented

Should be fixed by my PR #120.

This was closed by #120 (according to quick check, please reopen if it still occurs)