Skip to content

Whitespace between comments is no longer removed #193

Open
@chrispy-snps

Description

@chrispy-snps

In #184, processing was updated to be non-destructive. A side effect of this code change is that whitespace between comments is no longer removed:

import markdownify

md = markdownify.MarkdownConverter().convert

md("""
<p>line 1</p>
<!-- comment -->
<!-- comment -->
<!-- comment -->
<!-- comment -->
<p>line 2</p>""")
# 'line 1\n\n\n\n\n\nline 2'

This occurs because the code that conditionally omits whitespace looks at the adjacent siblings on both sides to check if they are block elements. Because comments are no longer deleted, this check sees comments instead of block elements.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions