summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/HTML5/Serializer/OutputRules.php4
-rw-r--r--test/HTML5/Serializer/OutputRulesTest.php34
2 files changed, 36 insertions, 2 deletions
diff --git a/src/HTML5/Serializer/OutputRules.php b/src/HTML5/Serializer/OutputRules.php
index bd97cb3..862ab55 100644
--- a/src/HTML5/Serializer/OutputRules.php
+++ b/src/HTML5/Serializer/OutputRules.php
@@ -57,7 +57,7 @@ class OutputRules implements \HTML5\Serializer\RulesInterface {
$this->inSvg = TRUE;
$name = Elements::normalizeSvgElement($name);
break;
- case 'mathml':
+ case 'math':
$this->inMathMl = TRUE;
break;
}
@@ -74,7 +74,7 @@ class OutputRules implements \HTML5\Serializer\RulesInterface {
case 'svg':
$this->inSvg = FALSE;
break;
- case 'mathml':
+ case 'math':
$this->inMathMl = FALSE;
break;
}
diff --git a/test/HTML5/Serializer/OutputRulesTest.php b/test/HTML5/Serializer/OutputRulesTest.php
index 768434c..70d3b7d 100644
--- a/test/HTML5/Serializer/OutputRulesTest.php
+++ b/test/HTML5/Serializer/OutputRulesTest.php
@@ -36,6 +36,13 @@ class OutputRulesTest extends \HTML5\Tests\TestCase {
return $method;
}
+ function getTraverserProtectedProperty($name) {
+ $class = new \ReflectionClass('\HTML5\Serializer\Traverser');
+ $property = $class->getProperty($name);
+ $property->setAccessible(true);
+ return $property;
+ }
+
function getOutputRules($options = array()) {
$options = $options + \HTML5::options();
$stream = fopen('php://temp', 'w');
@@ -220,4 +227,31 @@ class OutputRulesTest extends \HTML5\Tests\TestCase {
$this->assertRegExp('|<svg width="150" height="100" viewBox="0 0 3 2">|', stream_get_contents($stream, -1, 0));
}
+ function testMath() {
+ $dom = \HTML5::loadHTML('<!doctype html>
+ <html lang="en">
+ <body>
+ <div id="foo" class="bar baz">foo bar baz</div>
+ <math>
+ <mi>x</mi>
+ <csymbol definitionURL="http://www.example.com/mathops/multiops.html#plusminus">
+ <mo>&PlusMinus;</mo>
+ </csymbol>
+ <mi>y</mi>
+ </math>
+ </body>
+ </html>');
+
+ $stream = fopen('php://temp', 'w');
+ $t = new Traverser($dom, $stream, \HTML5::options());
+ $p = $this->getTraverserProtectedProperty('rules');
+ $o = $p->getValue($t);
+
+ $list = $dom->getElementsByTagName('math');
+ $o->element($list->item(0));
+ $content = stream_get_contents($stream, -1, 0);
+ $this->assertRegExp('|<math>|', $content);
+ $this->assertRegExp('|<csymbol definitionURL="http://www.example.com/mathops/multiops.html#plusminus">|', $content);
+ }
+
} \ No newline at end of file