Better integration with the existing code

This commit is contained in:
Domovoy 2012-09-14 05:50:35 +02:00
parent f9a9b70123
commit 09413a0f0a

View file

@ -127,6 +127,7 @@ class HTML5_TreeBuilder {
const NS_XLINK = 'http://www.w3.org/1999/xlink'; const NS_XLINK = 'http://www.w3.org/1999/xlink';
const NS_XML = 'http://www.w3.org/XML/1998/namespace'; const NS_XML = 'http://www.w3.org/XML/1998/namespace';
const NS_XMLNS = 'http://www.w3.org/2000/xmlns/'; const NS_XMLNS = 'http://www.w3.org/2000/xmlns/';
const NS_GOOGLE = 'http://base.google.com/ns/1.0';
public function __construct() { public function __construct() {
$this->mode = self::INITIAL; $this->mode = self::INITIAL;
@ -1430,6 +1431,14 @@ class HTML5_TreeBuilder {
// parse error // parse error
break; break;
/* Google */
case 'g:plusone':
/* Reconstruct the active formatting elements, if any. */
$this->reconstructActiveFormattingElements();
$this->insertForeignElement($token, self::NS_GOOGLE);
break;
/* A start tag token not covered by the previous entries */ /* A start tag token not covered by the previous entries */
default: default:
/* Reconstruct the active formatting elements, if any. */ /* Reconstruct the active formatting elements, if any. */
@ -3037,21 +3046,7 @@ class HTML5_TreeBuilder {
} }
private function insertElement($token, $append = true) { private function insertElement($token, $append = true) {
$sep_pos = strpos($token['name'],':'); $el = $this->dom->createElementNS(self::NS_HTML, $token['name']);
$ns_uri = self::NS_HTML;
if($sep_pos !== FALSE) {
// This tag has a namespace
$ns = substr($token['name'], 0, $sep_pos);
switch($ns) {
case 'g':
$ns_uri = 'http://base.google.com/ns/1.0';
break;
default:
logger("HTML5/TreeBuilder.php: Unknown namespace '". $ns ."', tag = ". $token['name'], LOGGER_DEBUG);
break;
}
}
$el = $this->dom->createElementNS($ns_uri, $token['name']);
if (!empty($token['attr'])) { if (!empty($token['attr'])) {
foreach($token['attr'] as $attr) { foreach($token['attr'] as $attr) {