I have a section of code that I am attempting to remove duplicate <br /> tags from. I understand that there are better ways to do this, but for the time being my only option is to do it client side with javascript/jquery (as I do not have control over the source html).
You can view the working example here to play around with it:
The text node looks like this:
<div class="show-tooltip-text">
<p><sup>2</sup>lots of text
can be seen here.
<br><br>another lines text
<br><br>another lines text
<br><br>another lines text
<br><br>
<br><br>
<br><br>another lines text
<br><br>
<br><br>another lines text
<br><br>another lines text
<br><br>another lines text
<br><br>another lines text
<br><br>another lines text
<br><br>another lines text
<br><br>another lines text
<br><br>
<br><br>another lines text
<br><br>another lines text
<br><br>another lines text</p>
</div>
I realize the problem is that prev doesn’t account for text as nodes. So when running prev on a single text node it only sees the <br> tags which results in it removing all but the very first <br>. My goal is to have it reduce every grouping of <br> tags down to 1 <br> tag. So I still want the spacing, I just want it to be a single space. It seems like the only way to do this might be a regex, but I’m not sure how to begin such a regex.