summaryrefslogtreecommitdiff
path: root/src/HTML5
diff options
context:
space:
mode:
Diffstat (limited to 'src/HTML5')
-rw-r--r--src/HTML5/Elements.php11
-rw-r--r--src/HTML5/Parser/DOMTreeBuilder.php16
-rw-r--r--src/HTML5/Parser/StringInputStream.php3
-rw-r--r--src/HTML5/Parser/Tokenizer.php6
-rw-r--r--src/HTML5/Parser/TreeBuildingRules.php11
-rw-r--r--src/HTML5/Serializer/OutputRules.php2
6 files changed, 29 insertions, 20 deletions
diff --git a/src/HTML5/Elements.php b/src/HTML5/Elements.php
index 0dabc3a..69d3882 100644
--- a/src/HTML5/Elements.php
+++ b/src/HTML5/Elements.php
@@ -1,9 +1,10 @@
<?php
+/**
+ * Provide general element functions.
+ */
namespace HTML5;
/**
- * Provide general element functions.
- *
* This class provides general information about HTML5 elements,
* including syntactic and semantic issues. Parsers and serializers can
* use this class as a reference point for information about the rules
@@ -532,6 +533,12 @@ class Elements {
/**
* Get the element mask for the given element name.
+ *
+ * @param string $name
+ * The name of the element.
+ *
+ * @return int
+ * The element mask.
*/
public static function element($name) {
if (isset(static::$html5[$name])) {
diff --git a/src/HTML5/Parser/DOMTreeBuilder.php b/src/HTML5/Parser/DOMTreeBuilder.php
index 094104e..13ae3bc 100644
--- a/src/HTML5/Parser/DOMTreeBuilder.php
+++ b/src/HTML5/Parser/DOMTreeBuilder.php
@@ -289,6 +289,11 @@ class DOMTreeBuilder implements EventHandler {
return;
}
+ // Special case handling for SVG.
+ if ($this->insertMode == static::IM_IN_SVG) {
+ $lname = Elements::normalizeSvgElement($lname);
+ }
+
// XXX: Not sure whether we need this anymore.
// if ($name != $lname) {
// return $this->quirksTreeResolver($lname);
@@ -301,8 +306,8 @@ class DOMTreeBuilder implements EventHandler {
}
//$this->current = $this->current->parentNode;
- if (!$this->autoclose($name)) {
- $this->parseError('Could not find closing tag for ' . $name);
+ if (!$this->autoclose($lname)) {
+ $this->parseError('Could not find closing tag for ' . $lname);
}
//switch ($this->insertMode) {
@@ -318,11 +323,6 @@ class DOMTreeBuilder implements EventHandler {
$this->insertMode = static::IM_IN_BODY;
break;
}
-
- // 8.2.5.4.7
- if ($name == 'sarcasm') {
- $this->text("Take a deep breath.");
- }
}
public function comment($cdata) {
@@ -372,7 +372,7 @@ class DOMTreeBuilder implements EventHandler {
// Important: The processor may modify the current DOM tree however
// it sees fit.
if (isset($this->processor)) {
- $res = $processor->process($this->current, $name, $data);
+ $res = $this->processor->process($this->current, $name, $data);
if (!empty($res)) {
$this->current = $res;
}
diff --git a/src/HTML5/Parser/StringInputStream.php b/src/HTML5/Parser/StringInputStream.php
index 0d2a7f3..ca5fee0 100644
--- a/src/HTML5/Parser/StringInputStream.php
+++ b/src/HTML5/Parser/StringInputStream.php
@@ -1,4 +1,7 @@
<?php
+/**
+ * Loads a string to be parsed.
+ */
namespace HTML5\Parser;
/*
diff --git a/src/HTML5/Parser/Tokenizer.php b/src/HTML5/Parser/Tokenizer.php
index 9866246..df77b5d 100644
--- a/src/HTML5/Parser/Tokenizer.php
+++ b/src/HTML5/Parser/Tokenizer.php
@@ -295,7 +295,7 @@ class Tokenizer {
return $this->bogusComment('</');
}
- $name = $this->scanner->charsUntil("\n\f \t>");
+ $name = strtolower($this->scanner->charsUntil("\n\f \t>"));
// Trash whitespace.
$this->scanner->whitespace();
@@ -475,7 +475,7 @@ class Tokenizer {
* The attribute value.
*/
protected function quotedAttributeValue($quote) {
- $stoplist = "\t\n\f" . $quote;
+ $stoplist = "\f" . $quote;
$val = '';
$tok = $this->scanner->current();
while (strspn($tok, $stoplist) == 0 && $tok !== FALSE) {
@@ -846,7 +846,7 @@ class Tokenizer {
$buffer .= $this->scanner->charsUntil($first);
// Stop as soon as we hit the stopping condition.
- if ($this->sequenceMatches($sequence)) {
+ if ($this->sequenceMatches($sequence) || $this->sequenceMatches(strtoupper($sequence))) {
return $buffer;
}
$buffer .= $this->scanner->current();
diff --git a/src/HTML5/Parser/TreeBuildingRules.php b/src/HTML5/Parser/TreeBuildingRules.php
index 0f1b3a5..b87c6b5 100644
--- a/src/HTML5/Parser/TreeBuildingRules.php
+++ b/src/HTML5/Parser/TreeBuildingRules.php
@@ -71,20 +71,19 @@ class TreeBuildingRules {
case 'rp':
return $this->handleRT($new, $current);
case 'optgroup':
- $this->closeIfCurrentMatches($new, $current, array('optgroup'));
+ return $this->closeIfCurrentMatches($new, $current, array('optgroup'));
case 'option':
- $this->closeIfCurrentMatches($new, $current, array('option', 'optgroup'));
+ return $this->closeIfCurrentMatches($new, $current, array('option', 'optgroup'));
case 'tr':
- $this->closeIfCurrentMatches($new, $current, array('tr'));
+ return $this->closeIfCurrentMatches($new, $current, array('tr'));
case 'td':
case 'th':
- $this->closeIfCurrentMatches($new, $current, array('th', 'td'));
+ return $this->closeIfCurrentMatches($new, $current, array('th', 'td'));
case 'tbody':
case 'thead':
case 'tfoot':
case 'table': // Spec isn't explicit about this, but it's necessary.
- $this->closeIfCurrentMatches($new, $current, array('thead', 'tfoot', 'tbody'));
-
+ return $this->closeIfCurrentMatches($new, $current, array('thead', 'tfoot', 'tbody'));
}
return $current;
diff --git a/src/HTML5/Serializer/OutputRules.php b/src/HTML5/Serializer/OutputRules.php
index bb0cb45..bc57346 100644
--- a/src/HTML5/Serializer/OutputRules.php
+++ b/src/HTML5/Serializer/OutputRules.php
@@ -120,7 +120,7 @@ class OutputRules implements \HTML5\Serializer\RulesInterface {
}
public function processorInstruction($ele) {
- $this->wr('<?')->wr($ele->target)->wr($ele->data)->wr(' ?>');
+ $this->wr('<?')->wr($ele->target)->wr(' ')->wr($ele->data)->wr('?>');
}
/**