matthewwithanm / matthewwithanm/python-markdownify

Whitespace between comments is no longer removed

Open
#193 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.2k
Forks
203
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the whitespace-handling logic that checks adjacent siblings, using the MarkdownConverter().convert example in the issue to reproduce the extra newlines between comments. Compare the behavior introduced by #184 and verify that the converted output no longer contains the unwanted whitespace between the comment nodes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.