public function bParse($oHtmlStr) { assert($oHtmlStr instanceof Ko_Html_Str); $this->_aChild = array(); $this->_vParseText($oHtmlStr); while (!$oHtmlStr->bEnd()) { $tag = $oHtmlStr->sGetTagStr(); if ('/' === $tag[0]) { $tag = substr($tag, 1); $oHtmlStr->vFind('>'); $oHtmlStr->vNext(); $this->_vCloseTag($tag); } else { $child = new Ko_Html_Node($this, $tag); if (!$child->_bParseAllAttr($oHtmlStr) || '!' === $tag[0] || in_array($tag, self::$s_aSingleTag, true)) { $child->_bClosed = true; } else { $child->_vParseChild($oHtmlStr); } $this->_aChild[] = $child; } if ($this->_bClosed) { break; } $this->_vParseText($oHtmlStr); } return true; }
public static function sParse($oFilter, $sHtml, $iMaxLength = 0, $sCharset = '') { assert(is_null($oFilter) || $oFilter instanceof IKo_Html_Filter); $htmlstr = new Ko_Html_Str($sHtml); $node = new Ko_Html_Node(); $node->bParse($htmlstr); if (!is_null($oFilter)) { $node->vAddFilter($oFilter); } $sRet = $node->sHtmlEx($iMaxLength, $sCharset); $node->vFreeParent(); return $sRet; }