codsen / codsen

a monorepo of npm packages

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Specify custom HTML tags Detergent shouldn't alter

rootwork opened this issue · comments

Package's name
detergent; possibly string-strip-html

Is your feature request related to a problem? Please describe.
I have content that already has some tags from MJML inside of it. One of these tags is mj-image which can look either like this:

<mj-image src="foo.jpg" />

or this:

<mj-image src="foo.jpg"></mj-image>

In other words, as a void/singleton element or as a regular element. What it cannot look like is this:

<mj-image src="foo.jpg">

When I run content with this tag through Detergent, even with stripHtml: false and useXHTML: true, it returns the tag this way:

</mj-image src="foo.jpg">

(If I use the version with the closing tag, it also returns this, but still changes the opening one.)

I assume if stripHtml is set to false it's not being run through string-strip-html at all, right? What else would be altering the tags?

Describe the solution you'd like

I can't figure out why it's doing anything with the tag at all, but since it's not a real HTML tag I assume Detergent is trying to parse it somehow. Is there some way to tell Detergent which custom tags not to parse? Or is there some setting in addition to stripHtml and useXHTML that says no, really, don't change void elements?

Thanks!

Describe alternatives you've considered

With useXHTML: false it has the same behavior. Other settings (like removeLineBreaks) don't seem to affect it either.

Sorry about the issue. Yeah, fixable, I'll have a look.

Thank you!

Closing, it's been solved since. Feel free to reopen the issue if I missed something. Thank you.