python-markdownify icon indicating copy to clipboard operation
python-markdownify copied to clipboard

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

Open chrispy-snps opened this issue 1 year ago • 1 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")

chrispy-snps avatar Sep 07 '24 11:09 chrispy-snps

Should be fixed by my PR #120.

jsm28 avatar Sep 09 '24 22:09 jsm28

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

AlexVonB avatar Nov 24 '24 19:11 AlexVonB