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

Markdown after self-closing html tag is not parsed #16

Closed
Bundas opened this issue Feb 26, 2020 · 3 comments
Closed

Markdown after self-closing html tag is not parsed #16

Bundas opened this issue Feb 26, 2020 · 3 comments
Labels
🙋 no/question This does not need any changes

Comments

@Bundas
Copy link

Bundas commented Feb 26, 2020

Markdown after self-closing html tag is not parsed

When there is a self closing tag (eg. <br/>) before markdown content, the markdown is not parsed and is shown as is.

Steps to reproduce

Example input:

<img src="https://a.storyblok.com/f/68034/756x1000/db92d9ed67/hc_3000_r.png" width="110" />
El <b>VF 1000 / 65R32 CFO 200A8 HC3000R TL</b> tiene un **nuevo** diseño de banda de rodadura

Expected behaviour

Img + El VF 1000 / 65R32 CFO 200A8 HC3000R TL tiene un nuevo diseño de banda de rodadura

Actual behaviour

Img + El VF 1000 / 65R32 CFO 200A8 HC3000R TL tiene un **nuevo** diseño de banda de rodadura

@Bundas Bundas added 🐛 type/bug This is a problem 🙉 open/needs-info This needs some more info labels Feb 26, 2020
@wooorm
Copy link
Member

wooorm commented Feb 27, 2020

This should work, could you provide an example of how you are doing all this?

@Bundas
Copy link
Author

Bundas commented Feb 27, 2020

@wooorm I was also checking if the input isn't somehow escaped but it is not so the problem is somewhere in the unified tree

import markdown from 'remark-parse'
import raw from 'rehype-raw'
import remark2rehype from 'remark-rehype'
import rehype2react from 'rehype-react'

const processor = unified()
  .use(markdown)
  .use(remark2rehype, { allowDangerousHTML: true })
  .use(raw)
  .use(rehype2react, {
    createElement: React.createElement,
  })

{processor.processSync(original).contents}

@wooorm
Copy link
Member

wooorm commented Feb 27, 2020

Ah, the problem is that you’re missing an empty line between HTML and Markdown. See #8 for more info.

If you want to enter markdown after block-level HTML again, you need that blank line. Without it, markdown parsers see it as one block of HTML.

@wooorm wooorm closed this as completed Feb 27, 2020
@wooorm wooorm added 🙋 no/question This does not need any changes and removed 🐛 type/bug This is a problem 🙉 open/needs-info This needs some more info labels Feb 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙋 no/question This does not need any changes
Development

No branches or pull requests

2 participants