| | |
| | | { |
| | | $result = array(); |
| | | |
| | | // Remove unwanted white-space characters so regular expressions below work better |
| | | $style = preg_replace('/[\n\r\s\t]+/', ' ', $style); |
| | | |
| | | foreach (explode(';', $style) as $declaration) { |
| | | if (preg_match('/^\s*([a-z\-]+)\s*:\s*(.*)\s*$/i', $declaration, $match)) { |
| | | $cssid = $match[1]; |
| | |
| | | $dump = ''; |
| | | |
| | | do { |
| | | switch($node->nodeType) { |
| | | switch ($node->nodeType) { |
| | | case XML_ELEMENT_NODE: //Check element |
| | | $tagName = strtolower($node->tagName); |
| | | if ($callback = $this->handlers[$tagName]) { |
| | |
| | | case XML_HTML_DOCUMENT_NODE: |
| | | $dump .= $this->dumpHtml($node, $level); |
| | | break; |
| | | |
| | | case XML_DOCUMENT_TYPE_NODE: |
| | | break; |
| | | |
| | | default: |
| | | $dump .= '<!-- node type ' . $node->nodeType . ' -->'; |
| | | } |
| | | } while($node = $node->nextSibling); |
| | | } |
| | | while($node = $node->nextSibling); |
| | | |
| | | return $dump; |
| | | } |
| | |
| | | { |
| | | // special replacements (not properly handled by washtml class) |
| | | $html_search = array( |
| | | '/(<\/nobr>)(\s+)(<nobr>)/i', // space(s) between <NOBR> |
| | | '/<title[^>]*>[^<]*<\/title>/i', // PHP bug #32547 workaround: remove title tag |
| | | '/^(\0\0\xFE\xFF|\xFF\xFE\0\0|\xFE\xFF|\xFF\xFE|\xEF\xBB\xBF)/', // byte-order mark (only outlook?) |
| | | '/<html\s[^>]+>/i', // washtml/DOMDocument cannot handle xml namespaces |
| | | // space(s) between <NOBR> |
| | | '/(<\/nobr>)(\s+)(<nobr>)/i', |
| | | // PHP bug #32547 workaround: remove title tag |
| | | '/<title[^>]*>[^<]*<\/title>/i', |
| | | // remove <!doctype> before BOM (#1490291) |
| | | '/<\!doctype[^>]+>[^<]*/im', |
| | | // byte-order mark (only outlook?) |
| | | '/^(\0\0\xFE\xFF|\xFF\xFE\0\0|\xFE\xFF|\xFF\xFE|\xEF\xBB\xBF)/', |
| | | // washtml/DOMDocument cannot handle xml namespaces |
| | | '/<html\s[^>]+>/i', |
| | | ); |
| | | |
| | | $html_replace = array( |
| | | '\\1'.' '.'\\3', |
| | | '', |
| | | '', |
| | | '', |
| | | '<html>', |
| | | ); |
| | | $html = preg_replace($html_search, $html_replace, trim($html)); |