I want manipulate an html string, in vanillaJS I would do it something like this:
let HTMLString = '<p>hello</p>
<style>
p{
color:black
}
<p>world</p>
'
const parser = new DOMParser();
const doc = parser.parseFromString(HTMLString, "text/html");
doc.querySelectorAll('style').forEach(item => item.remove())
this works in react aswell, but i believe since next compiles server side it just throws DOMParser is not defined
, i've tried packages like html-react-parser
, they just parse the html into react elements and offer very limited functionality after that, my last resort is using regex for this, but i've that's not a good idea.
any help in this would be good, thanks
getStaticProps
/getSeverSideProps
)? – Frons