string-strip-html: removes <%= %> tags
See original GitHub issuePackage’s name
string-strip-html@8.0.1
Describe the bug
string-strip-html
is removing <%= %>
tags along with everything inside them.
To Reproduce
const {stripHtml} = require('string-strip-html')
const plaintext = stripHtml('<div>My variable: <%= @var %></div>').result
This outputs: My variable:
Expected behavior
Should output: My variable: <%= @var %>
Additional context
Reported in https://github.com/maizzle/framework/issues/394 where we currently use v7.0.2, but I’ve just tested with v8.0.1 and the bug is still present.
P.S.: it’s great to have you back here 🥳
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:10 (7 by maintainers)
Top Results From Across the Web
string-strip-html - npm
Strip HTML tags from strings. No parser, accepts mixed sources.. Latest version: 13.0.6, last published: 5 days ago.
Read more >4 Ways to Strip & Remove HTML Tags In Javascript - Code Boxx
This tutorial will walk through ways to strip or remove HTML tags in Javascript. ... Use a library such as String Strip HTML....
Read more >string-strip-html open source npm package - Codsen
These tags will be removed along with their children tags. Set it to something falsy to turn it off. You can set it...
Read more >string-strip-html | Yarn - Package Manager
Strip HTML tags from strings. No parser, accepts mixed sources. code, extract, from, html. readme. string-strip- ...
Read more >How to Strip HTML Tags From String in JavaScript - Linux Hint
This method can be implemented in such a way that if the particular string includes the “<script>” element, string-strip-html() will remove it along...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s already fixed on local, I’m aiming to release this weekend. Algorithm wise, I DRY’ed up all asserts on
"<"
(assumption that tag should start here) or">"
(assumption that tag would end here) into separate functions, then beefed them up at that single location with checks, do%
precede/follow. Originally, I had added the check against%
following a single opening, on only one clause, inline. Now it’s checking everywhere, properly. It’s a good future-proof measure, we’ll be able to supplement more templating language types that way. Maybe another templating language like<$... $>
or something…on it. sorry about that