-
Notifications
You must be signed in to change notification settings - Fork 33
Description
The Markdown plugin uses the Showdown library under the hood. And wrapping markdown in paragraph tags is the default behavior that might cause some issues and sometimes highly undesirable (e.g., see https://codepen.io/dmitrysharabin/pen/zYwxEPJ?editors=1100).
It is not a rare problem at all. There are issues concerning it in the Showdown repo as well:
- need to render html without paragraph tags showdownjs/showdown#493
- Possible to suppress the encapsulating <p> tags? showdownjs/showdown#573
- How to prevent showdown from wrapping html in paragraph tags showdownjs/showdown#588
As @tivie mentioned in their comment: Showdown does not support selective conversion (the ability to only parse and convert certain markdown elements), however, one can create an extension that removes disallowed “tags”.
So, we could add this code (with some modifications if needed) to our plugin:
showdown.extension("remove-extra-paragraphs", function () {
return [{
type: "output",
filter: function (markdown) {
return markdown.replace(/<\/?p[^>]*>/g, "");
}
}];
});However, we need to decide whether we want this extension to be enabled plugin-wise or property-wise. If plugin-wise, how can we distinguish when to apply some extra transformations on the markdown and when don't? If property-wise, should authors add some extra attributes to the property, or maybe they should add a class?
Are there any other cases we should take into account?