protected static function _autoTag_isBetweenHtmlTags($html, $position) { $htmlLength = utf8_strlen($html); // look for <a> and </a> $aBefore = Tinhte_XenTag_Helper::utf8_strripos($html, '<a', $position - $htmlLength); if ($aBefore !== false) { $aAfter = Tinhte_XenTag_Helper::utf8_stripos($html, '</a>', $aBefore); if ($aAfter > $position) { // too bad, this position is between <a> and </a> return true; } } // now that we are not inside <a /> // we have to make sure we are not in the middle of any tag $symbolBefore = Tinhte_XenTag_Helper::utf8_strrpos($html, '<', $position - $htmlLength); if ($symbolBefore !== false) { $symbolAfter = utf8_strpos($html, '>', $symbolBefore); if ($symbolAfter > $position) { // now this is extremly bad, get out of here now! return true; } } return false; }