This is to deal with what's described in the comments of #1023 (closed). Sometimes XSweet is turning math, which should look something like this:
<p><math-display>...math...</math-display></p>
to this:
<h4><h4><math-display>...math...</math-display></h4></h4>
If that's not invalid HTML, it's not quite sensical, and it breaks further parsing – so the math tags get thrown away. What this fix does is to replace <h4><h4>
and </h4></h4>
with <p>
and </p>
respectively; with this in place, parsing works normally.
However! This is basically plastering over a problem that's coming from XSweet. I don't know why we're getting the nested <h4>
s; I don't know if they're always <h4>
s. If there's a way to fix this problem on that end, that would be a greatly superior solution.