I'm attempting to use this library more for just some basic text styling on some strings that will be injected into HTML thereafter. So, I'd like to turn something like this:
Please do **this thing** more than that thing
in to:
Please do <strong>this thing</strong> more than that thing
Without the rest of the markup I'm currently getting:
<p>Please do <strong>this thing</strong> more than that thing
Which is causing issues with my implementation.
I didn't see a sign of it in the docs, but is it possible to only support certain elements of markdown (like bolding/italics/etc), suppress the encapsulating tags, or anything else I could use to address this?
Thanks!
Hey @Dygerati
Showdown does not support selective conversion (the ability to only parse and convert certain markdown elements).
Depending on your requirements, though, you can create an extension that removes disallowed "tags".
example (fiddle here):
showdown.extension('only-inline-stuff', function () {
return [{
type: 'output',
filter: function (text) {
// remove paragraphs
text = text.replace(/<\/?p[^>]*>/g, '');
// remove code (if you want)
text = text.replace(/<\/?code[^>]*>/g, '');
//add other stuff here that you want to remove
// text = text.replace(, '');
return text;
}
}];
});
@Dygerati Closing issue (no activity for 26 days). Feel free to reopen the issue, if you feel you still need help.
Donate
As you know, ShowdownJS is a free library and it will remain free forever. However, maintaining and improving the library costs time and money.
If you like our work and find our library useful, please donatethrough Pledgie ordirectly through paypal!! Your contribution will be greatly appreciated and help us continue to develop this awesome library.
Most helpful comment
Hey @Dygerati
Showdown does not support selective conversion (the ability to only parse and convert certain markdown elements).
Depending on your requirements, though, you can create an extension that removes disallowed "tags".
example (fiddle here):