I have an html template and I want to remove the extra <p></p> from it via JS.
P.S. I cannot have more than one empty p.
Example:
const htmlTemplate = `
<p>Rich editor text</p>
<p></p>
<p></p> // <-- Remove these extra elements
<p>1.2.3</p>
<p>test432</p>
<p></p>
<p></p> // <--
<p>lorem</p>
<p></p>
<p></p> // <--
<p></p> // <--
<p>ipsum dolor amet</p>
`
Result:
const result = `
<p>Rich editor text</p>
<p></p>
<p>1.2.3<br></p>
<p>test432</p>
<p></p>
<p>lorem</p>
<p></p>
<p>ipsum dolor amet</p>
`
<p></p>in the output? You do not want more than one emptypconsecutively? – adiga 2 days ago<p></p>those I are not extra? – Nicolae Maties 2 days ago