Open girishkamat opened 3 years ago
The HTML isn't wrapped in a <p>
tag: each paragraph is. That's the correct behavior according to the spec.
I'd suggest the library stay as-is for this case, and instead you could strip the <p>
tags yourself or fix the styling problems you're seeing.
@girishkamat Well, wrapping into a paragraph or now depends on your input, so it's not certain that there will be a paragraph to strip at all. If you have a specific spec on your input, you might try to strip paragraph manually indeed. You might also try to disable paragraphs rendering at all in html generators, but that will be cumbersome, I believe.
What's your specific use case?
I will share my use case which led to manually stripping <body>
and <p>
tags. In short, my use case is inject markdown into existing html.
Longer version: I'm working on an Android app where I fetch user comments from external API which are formatted as plain html. I have to substitute parts of the html when user taps on specific areas ( spoilers). (Unfortunately) spoilers are stored as Markdown, so I parse related markdown and I want to inject parsed output into existing html - so as per my understanding I shouldn't need additional <body>
or <p>
tags as they should be a result of parent's html layout.
Sample mentioned in Readme file produces <body><p>Some <em>Markdown</em></p></body>
while in my case I just need Some <em>Markdown</em>
part.
Ideally I wouldn't mix formats, but that's outside my control, and it is highly unlikely it will be changed on the backend side so... 🤷
Same for all usages in the IntelliJ IDEA codebase where old markdown library was used :) It is up to the client to wrap into <body></body>
if needed.
Solution: use parse(IElementType("ROOT"), markdownText)
instead of buildMarkdownTreeFromString(markdownText)
.
The below code generates HTML wrapped in <p> tag by default. Is there a way to exclude the wrapper tag? Its causing styling issues.