I need to limit the output of Magento's breadcrumbs across my entire site, and I think I am most of the way there on this script.
    $breadcrumbs = "";
    $bleng = 0;
    foreach($crumbs as $_crumbName=>$_crumbInfo):
        $breadcrumbs .= "<li class=\"".$_crumbName."\">";
        $bleng = $bleng + strlen($_crumbName);
        if($_crumbInfo['link']):
            $breadcrumbs .= "<a href=\"".$_crumbInfo['link']."\" title=\"".$this->htmlEscape($_crumbInfo['title'])."\">".$this->htmlEscape($_crumbInfo['label'])."</a>";
            $bleng = $bleng + strlen($this->htmlEscape($_crumbInfo['label']));
        elseif($_crumbInfo['last']):
            $breadcrumbs .= "<strong>".$this->htmlEscape($_crumbInfo['label'])."</strong>";
            $bleng = $bleng + strlen($this->htmlEscape($_crumbInfo['label']));
        else:
            $breadcrumbs .= $this->htmlEscape($_crumbInfo['label']);
            $bleng = $bleng + strlen($this->htmlEscape($_crumbInfo['label']));
       endif;
       if(!$_crumbInfo['last']):
           $breadcrumbs .= "<span>></span>";
       endif;
       $breadcrumbs .= "</li>";
    endforeach;
    if ($bleng > 70): // Arbitrary threshold
        $trimmed = $breadcrumbs;
        echo substr($trimmed, 0, 70);
        echo $trimmed."...";
    else:
        echo $breadcrumbs;
    endif;
The problem with this quick modification is that $bleng is counting characters in the html markup as well as in the visible text. What I need is to count only the visible text (breadcrumb 'labels') and trim $breadcrumbs accordingly. As it is, this script is trimming the  and  tags from the string on top of any visible text, but adding them back in at the end doesn't seem to work using:
echo $trimmed."...</a></li>";
I suspect there is an SEO-friendlier JS way to do this that doesn't require that I use an arbitrary character limit. I'm happy to use either PHP or JS for this, so long as it works. Any suggestions?