36 $this->tokens = array();
37 $this->last_token_was_empty =
false;
41 $this->parent_handler = set_error_handler(array($this,
'muteStrictErrorHandler'));
43 $parser =
new XML_HTMLSax3();
44 $parser->set_object($this);
45 $parser->set_element_handler(
'openHandler',
'closeHandler');
46 $parser->set_data_handler(
'dataHandler');
47 $parser->set_escape_handler(
'escapeHandler');
50 $parser->set_option(
'XML_OPTION_ENTITIES_PARSED', 1);
52 $parser->parse($string);
54 restore_error_handler();
63 public function openHandler(&$parser, $name, $attrs, $closed) {
65 foreach ($attrs as $key => $attr) {
70 $this->last_token_was_empty =
true;
74 $this->stack[] = $name;
85 if ($this->last_token_was_empty) {
86 $this->last_token_was_empty =
false;
90 if (!empty($this->stack)) array_pop($this->stack);
98 $this->last_token_was_empty =
false;
107 if (strpos(
$data,
'--') === 0) {
110 if (strlen(
$data) >= 2 && substr(
$data, -2) ==
"--") {
113 if (isset($this->stack[
sizeof($this->stack) - 1]) &&
114 $this->stack[
sizeof($this->stack) - 1] ==
"style") {
119 $this->last_token_was_empty =
false;
133 if ($errno == E_STRICT)
return;
134 return call_user_func($this->parent_handler, $errno, $errstr, $errfile, $errline, $errcontext);