I solved this by just stripping XHTML tags out of the truncated content. I keep the excerpts small enough that it is fine if it is condensed into a single paragraph.
I use word_limiter_plus and at the beginning of the word_limiter_plus function in the plugin file, I just added “$str = strip_tags($str);”, i.e:
// ----------------------------------------
// Word limiter
// ----------------------------------------
function word_limiter_plus($str, $if_Exceeds = 500, $stop_after = 500, $the_link = "")
{
$str = strip_tags($str);
if (strlen($str) < $stop_after)
{
And then I just put my truncated content inside of <p> tags:
<p>{exp:word_limit_plus if_exceeds="N" stop_after="M" the_link="XXX"}{body}{/exp:word_limit_plus}</p>
And I don’t have to worry about broken tags then.
Other than stripping the tags, you’d have to do some HTML parsing or DOM tree parsing to keep track of the tags in order to properly close them all.