Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

heading inside anchor renders to invalid markdown #409

Open
da1z opened this issue May 4, 2022 · 3 comments · May be fixed by #419
Open

heading inside anchor renders to invalid markdown #409

da1z opened this issue May 4, 2022 · 3 comments · May be fixed by #419

Comments

@da1z
Copy link

da1z commented May 4, 2022

                    <a
                        href="some url">
                        <h3>
                            <strong>My hading</strong></h3>
                    </a>

this being converted to markdown as

[

### **My hading**

](some url)

which is not really valid. Is there workaround to make it converting to something like?

### [**MyHeading**](some url)

@da1z da1z changed the title hading inside anchor renders to invalid markdown heading inside anchor renders to invalid markdown May 4, 2022
@uuf6429
Copy link

uuf6429 commented Aug 15, 2022

I have the same problem, but with divs instead of headlines.

@uuf6429
Copy link

uuf6429 commented Aug 15, 2022

My solution to this (and since I'm preprocessing the html anyway because of #415):

  document.querySelectorAll('a > div > img, a > h1 > img, a > h2 > img, a > h3 > img').forEach(img => {
    const blockElem = img.parentNode;
    blockElem.replaceWith(...Array.from(blockElem.childNodes));
  });

This assumes you are using something like jsdom or domino to preprocess the html.

@Ndpnt
Copy link

Ndpnt commented Aug 31, 2022

Same problem but with paragraph inside anchors.

Ndpnt added a commit to OpenTermsArchive/turndown that referenced this issue Aug 31, 2022
Ndpnt added a commit to OpenTermsArchive/turndown that referenced this issue Aug 31, 2022
@Ndpnt Ndpnt linked a pull request Aug 31, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants