From c1581031d404574a32c4cb1aa72f59f0f5f74250 Mon Sep 17 00:00:00 2001 From: Asmir Mustafic Date: Sat, 29 Nov 2014 01:01:45 +0100 Subject: [PATCH] Added support for dashes in element tag names (closes #65) --- src/HTML5/Parser/Tokenizer.php | 2 +- test/HTML5/Html5Test.php | 6 ++++++ test/HTML5/Parser/TokenizerTest.php | 1 - 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/HTML5/Parser/Tokenizer.php b/src/HTML5/Parser/Tokenizer.php index 92510de..f7b450f 100644 --- a/src/HTML5/Parser/Tokenizer.php +++ b/src/HTML5/Parser/Tokenizer.php @@ -353,7 +353,7 @@ protected function tagName() } // We know this is at least one char. - $name = strtolower($this->scanner->charsWhile(":0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + $name = strtolower($this->scanner->charsWhile(":_-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); $attributes = array(); $selfClose = false; diff --git a/test/HTML5/Html5Test.php b/test/HTML5/Html5Test.php index 2b46b23..0ab367c 100644 --- a/test/HTML5/Html5Test.php +++ b/test/HTML5/Html5Test.php @@ -259,6 +259,12 @@ public function testElements() $res = $this->cycleFragment(''); $this->assertRegExp('||', $res); + // Elements with dashes and underscores + $res = $this->cycleFragment(''); + $this->assertRegExp('||', $res); + $res = $this->cycleFragment(''); + $this->assertRegExp('||', $res); + // Should have no closing tag. $res = $this->cycle('
'); $this->assertRegExp('|
|', $res); diff --git a/test/HTML5/Parser/TokenizerTest.php b/test/HTML5/Parser/TokenizerTest.php index bf04c58..8ff4d5c 100644 --- a/test/HTML5/Parser/TokenizerTest.php +++ b/test/HTML5/Parser/TokenizerTest.php @@ -557,7 +557,6 @@ public function testIllegalTagNames() '' => 'static', '' => 'h', '' => 'st', - '' => 'a' ); foreach ($cases as $html => $expected) {