matthewwithanm / matthewwithanm/python-markdownify

Handling links for headers

Open
#30 3 comments 3 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

The following code....

from markdownify import markdownify, ATX

clean_html = '''
<a href="https://www.google.com">
<h4>Google Search</h4>
</a>
'''

md_content = markdownify(clean_html, heading_style=ATX)

print(md_content)

generates...

  [#### Google Search](https://www.google.com) 

It should generate the following MD instead, isn't it?

#### [Google Search](https://www.google.com)

Also, there are 2 white spaces in front that are unnecessary which confuses reliable MD readers.

Fixing the unnecessary white spaces in front of headers in ATX style and a better handling of the <a> tag would allow to generate much higher quality MD output for foundational html tag structures.

Thanks!

Sharing a good reference for me: Markdown Reference Guide

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 by reproducing the Python snippet in the issue and inspect how nested and

elements are converted with ATX headings. The change is done when the output places the link inside the heading, removes the leading spaces, and preserves the expected Markdown shown in the report.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.