I'm afraid not. The missing closing tag could be for bold, italics, or the end of a list, among other things. That would mess up the rest of your code.
If you look at the code of the ellipsis filter in the current version of Revo, it has a solution using regular expression matching.
Here is a version of it modified to set the placeholder for you. The problem is that the hidden part will then have a closing tag for an element that is not open. In addition, in the hidden div you may have list items that are no longer in the list, bold and italic text that's not bold or italic, etc. It will usually work, but it won't be valid HTML. It would be possible to remove the orphaned closing tags, but that wouldn't solve the problem of the misformatting in the hidden div.
<?php
$limit= intval($m_val) ? intval($m_val) : 100;
$pad = $this->modx->getOption('ellipsis_filter_pad',null,'…');
/* ensure that filter correctly counts special chars */
$output = html_entity_decode($output,ENT_COMPAT,$encoding);
$len = $usemb ? mb_strlen($output) : strlen($output);
if ($limit > $len) $limit = $len;
$breakpoint = $usemb ? mb_strpos($output," ",$limit,$encoding) : strpos($output, " ", $limit);
if (false !== $breakpoint) {
if ($breakpoint < $len - 1) {
$partial = $usemb ? mb_substr($output, 0, $breakpoint,$encoding) : substr($output, 0, $breakpoint);
$output = $partial . $pad;
}
}
$opened = array();
if (preg_match_all("/<(\/?[a-z]+)>?/i", $output, $matches)) {
foreach ($matches[1] as $tag) {
if (preg_match("/^[a-z]+$/i", $tag, $regs)) {
$strLower = $usemb ? mb_strtolower($regs[0],$encoding) : strtolower($regs[0]);
if ($strLower != 'br' || $strLower != 'hr') {
$opened[] = $regs[0];
}
} elseif (preg_match("/^\/([a-z]+)$/i", $tag, $regs)) {
unset($opened[array_pop(array_keys($opened, $regs[1]))]);
}
}
}
if ($opened) {
$tagstoclose = array_reverse($opened);
foreach ($tagstoclose as $tag) $output .= "</$tag>";
}
/* I added this part */
$modx->setPlaceholder('extra', substr($input, strlen($output)));
------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using.
MODX info for everyone:
http://bobsguides.com/modx.html