From 10e129bd8be814b3b8a327416c2c4e1d67b0f678 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Mon, 4 Nov 2013 16:57:29 -0500 Subject: #20 Some of the parser rules, for special cases, were not returning the element to use as the current element. This caused the current parser element to get messed up. --- src/HTML5/Parser/TreeBuildingRules.php | 11 +++++------ test/HTML5/Parser/TreeBuildingRulesTest.php | 11 +++++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) 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/test/HTML5/Parser/TreeBuildingRulesTest.php b/test/HTML5/Parser/TreeBuildingRulesTest.php index fe02893..a247cea 100644 --- a/test/HTML5/Parser/TreeBuildingRulesTest.php +++ b/test/HTML5/Parser/TreeBuildingRulesTest.php @@ -62,4 +62,15 @@ class TreeBuildingRulesTest extends \HTML5\Tests\TestCase { $this->assertEquals('dd', $list->lastChild->tagName); } + public function testTable() { + $html = sprintf(self::HTML_STUB, '
foobarbaz'); + $doc = $this->parse($html); + + $list = $doc->getElementById('a'); + + $this->assertEquals(3, $list->childNodes->length); + $this->assertEquals('th', $list->firstChild->tagName); + $this->assertEquals('td', $list->lastChild->tagName); + } + } -- cgit v1.2.3 From de8a709bc9d2a1fc0e1b027aa440272f461c4b91 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Mon, 4 Nov 2013 16:59:47 -0500 Subject: Updated the Relese notes --- RELEASE.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/RELEASE.md b/RELEASE.md index 89267c7..d999b36 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -2,3 +2,7 @@ 1.0.1 (unreleased) - CDATA encoding is improved. (Non-standard; Issue #19) +- Some parser rules were not returning the new current element. (Issue #20) + +1.0.0 (2013-10-02) +- Initial release. -- cgit v1.2.3 From d37bff1a529551ae812b2c0eabd38cf93a08b38c Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Tue, 5 Nov 2013 10:38:05 -0500 Subject: Adding phpunit back to composer.json. The require-dev is only fired off when this library is the root project. When included as a library in another project require-dev items are not installed. --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index d574580..d0f2917 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,9 @@ "ext-libxml" : "*", "php" : ">=5.3.0" }, + "require-dev": { + "phpunit/phpunit" : "*" + }, "autoload": { "psr-0": {"HTML5": "src"} } -- cgit v1.2.3 From 9716ab044129561145c382df264f67f5b36d03ed Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Tue, 5 Nov 2013 10:40:15 -0500 Subject: Composer is already in Travis CI but is out of date. Switching from installing it to updating it. --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e01eb12..eb2430e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,6 @@ notifications: irc: "irc.freenode.net#masterminds" before_script: - - curl -s http://getcomposer.org/installer | php - - php composer.phar install + - composer self-update script: phpunit test/HTML5 \ No newline at end of file -- cgit v1.2.3 From fee0ca041c8b2f1b6e6c2ad2eaadf3e5904eba11 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Tue, 5 Nov 2013 10:41:39 -0500 Subject: Adding composer install --dev back in. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index eb2430e..442b17e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,5 +10,6 @@ notifications: before_script: - composer self-update + - composer install --dev script: phpunit test/HTML5 \ No newline at end of file -- cgit v1.2.3 From cdd388704ecee21e5d3bd30bbd5af499fc766d3f Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Tue, 5 Nov 2013 10:46:12 -0500 Subject: Adding coveralls support. --- .travis.yml | 3 +++ composer.json | 1 + 2 files changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 442b17e..289f9fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,4 +12,7 @@ before_script: - composer self-update - composer install --dev +after_script: + - php vendor/bin/coveralls -v + script: phpunit test/HTML5 \ No newline at end of file diff --git a/composer.json b/composer.json index d0f2917..a9dbc42 100644 --- a/composer.json +++ b/composer.json @@ -20,6 +20,7 @@ "php" : ">=5.3.0" }, "require-dev": { + "satooshi/php-coveralls": "0.6.*", "phpunit/phpunit" : "*" }, "autoload": { -- cgit v1.2.3 From f0bd0b439c5765718d5ceed04464993a52936ce3 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Tue, 5 Nov 2013 10:51:34 -0500 Subject: Adding release badge linked to Packagist to README. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0daae87..b8d4100 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ But after some initial refactoring work, we began a new parser. - DOM tree builder - Interoperability with QueryPath [[in progress](https://github.com/technosophos/querypath/issues/114)] -[![Build Status](https://travis-ci.org/Masterminds/html5-php.png?branch=master)](https://travis-ci.org/Masterminds/html5-php) +[![Build Status](https://travis-ci.org/Masterminds/html5-php.png?branch=master)](https://travis-ci.org/Masterminds/html5-php) [![Latest Stable Version](https://poser.pugx.org/masterminds/html5/v/stable.png)](https://packagist.org/packages/masterminds/html5) ## Installation -- cgit v1.2.3 From b35bb36ba5abffaef4644e2dbfe503a60ad2ff98 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Tue, 5 Nov 2013 11:25:15 -0500 Subject: Added code coverage to Travis CI so it can be passed to coveralls. --- .travis.yml | 4 ++++ phpunit.xml.dist | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 phpunit.xml.dist diff --git a/.travis.yml b/.travis.yml index 289f9fe..aaf85dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,10 @@ before_script: - composer self-update - composer install --dev +script: + - mkdir -p build/logs + - phpunit -c phpunit.xml.dist + after_script: - php vendor/bin/coveralls -v diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..81df747 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,21 @@ + + + + + test/HTML5/ + + + + + + + -- cgit v1.2.3 From f4a977bbba4bd4ff75acccb385f0ddad040fff9b Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Tue, 5 Nov 2013 11:48:10 -0500 Subject: Added code coverage to README and updated the RELEASE notes. --- README.md | 2 +- RELEASE.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b8d4100..8344c1c 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ But after some initial refactoring work, we began a new parser. - DOM tree builder - Interoperability with QueryPath [[in progress](https://github.com/technosophos/querypath/issues/114)] -[![Build Status](https://travis-ci.org/Masterminds/html5-php.png?branch=master)](https://travis-ci.org/Masterminds/html5-php) [![Latest Stable Version](https://poser.pugx.org/masterminds/html5/v/stable.png)](https://packagist.org/packages/masterminds/html5) +[![Build Status](https://travis-ci.org/Masterminds/html5-php.png?branch=master)](https://travis-ci.org/Masterminds/html5-php) [![Latest Stable Version](https://poser.pugx.org/masterminds/html5/v/stable.png)](https://packagist.org/packages/masterminds/html5) [![Coverage Status](https://coveralls.io/repos/Masterminds/html5-php/badge.png?branch=master)](https://coveralls.io/r/Masterminds/html5-php?branch=master) ## Installation diff --git a/RELEASE.md b/RELEASE.md index d999b36..c85c65d 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -3,6 +3,7 @@ 1.0.1 (unreleased) - CDATA encoding is improved. (Non-standard; Issue #19) - Some parser rules were not returning the new current element. (Issue #20) +- Added, to the README, details on code test coverage and to packagist version. 1.0.0 (2013-10-02) - Initial release. -- cgit v1.2.3 From 5a061feb7f054ff3e27a5baf1bafa876ca68226a Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Tue, 5 Nov 2013 22:00:10 -0500 Subject: Adding interfaces and autogenerated file to code coverage blacklist. --- phpunit.xml.dist | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 81df747..9f840dd 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -5,6 +5,13 @@ test/HTML5/ + + + src/HTML5/Parser/InputStream.php + src/HTML5/Serializer/RulesInterface.php + src/HTML5/Entities.php + + Date: Tue, 5 Nov 2013 22:06:38 -0500 Subject: Added more tests for the HTML5 class to complete test coverage. --- test/HTML5/Html5Test.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/HTML5/Html5Test.php b/test/HTML5/Html5Test.php index 13f5b19..1d3d7ab 100644 --- a/test/HTML5/Html5Test.php +++ b/test/HTML5/Html5Test.php @@ -26,6 +26,15 @@ class Html5Test extends TestCase { $dom = \HTML5::load(__DIR__ . '/Html5Test.html'); $this->assertInstanceOf('\DOMDocument', $dom); $this->assertEmpty($dom->errors); + + $file = fopen(__DIR__ . '/Html5Test.html', 'r'); + $dom = \HTML5::load($file); + $this->assertInstanceOf('\DOMDocument', $dom); + $this->assertEmpty($dom->errors); + + $dom = \HTML5::loadHTMLFile(__DIR__ . '/Html5Test.html'); + $this->assertInstanceOf('\DOMDocument', $dom); + $this->assertEmpty($dom->errors); } public function testLoadHTML() { -- cgit v1.2.3 From 26ccf6eec90e37636982f08ac5d070658a7bd0a5 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Tue, 5 Nov 2013 22:38:08 -0500 Subject: Added tests for the output of processor instructions that lead to fixing that method. --- src/HTML5/Serializer/OutputRules.php | 2 +- test/HTML5/Serializer/OutputRulesTest.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) 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('?>'); } /** diff --git a/test/HTML5/Serializer/OutputRulesTest.php b/test/HTML5/Serializer/OutputRulesTest.php index a451055..61e2d50 100644 --- a/test/HTML5/Serializer/OutputRulesTest.php +++ b/test/HTML5/Serializer/OutputRulesTest.php @@ -330,4 +330,15 @@ class OutputRulesTest extends \HTML5\Tests\TestCase { $this->assertRegExp('||', $content); } + function testProcessorInstruction() { + $dom = \HTML5::loadHTMLFragment(''); + + $stream = fopen('php://temp', 'w'); + $r = new OutputRules($stream, \HTML5::options()); + $t = new Traverser($dom, $stream, $r, \HTML5::options()); + + $r->processorInstruction($dom->firstChild); + $content = stream_get_contents($stream, -1, 0); + $this->assertRegExp('|<\?foo bar \?>|', $content); + } } -- cgit v1.2.3 From 5734589d119502ddb81211fb6c3b55e28bc5eed3 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Tue, 5 Nov 2013 22:46:44 -0500 Subject: Added traverser test coverage for processing instructions. --- test/HTML5/Serializer/TraverserTest.php | 37 ++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/test/HTML5/Serializer/TraverserTest.php b/test/HTML5/Serializer/TraverserTest.php index 6fa5c1e..5816bfc 100644 --- a/test/HTML5/Serializer/TraverserTest.php +++ b/test/HTML5/Serializer/TraverserTest.php @@ -59,20 +59,33 @@ class TraverserTest extends \HTML5\Tests\TestCase { $this->assertInstanceOf('\HTML5\Serializer\Traverser', $t); } - function testFragment() { - $html = 'foo
bar
'; - $input = new \HTML5\Parser\StringInputStream($html); - $dom = \HTML5::parseFragment($input); + function testFragment() { + $html = 'foo
bar
'; + $input = new \HTML5\Parser\StringInputStream($html); + $dom = \HTML5::parseFragment($input); - //fprintf(STDOUT, print_r($dom, TRUE)); + $this->assertInstanceOf('\DOMDocumentFragment', $dom); - $this->assertInstanceOf('\DOMDocumentFragment', $dom); + $stream = fopen('php://temp', 'w'); + $r = new OutputRules($stream, \HTML5::options()); + $t = new Traverser($dom, $stream, $r, \HTML5::options()); + + $out = $t->walk(); + $this->assertEquals($html, stream_get_contents($stream, -1, 0)); + } + + function testProcessorInstruction() { + $html = ''; + $input = new \HTML5\Parser\StringInputStream($html); + $dom = \HTML5::parseFragment($input); - $stream = fopen('php://temp', 'w'); - $r = new OutputRules($stream, \HTML5::options()); - $t = new Traverser($dom, $stream, $r, \HTML5::options()); + $this->assertInstanceOf('\DOMDocumentFragment', $dom); - $out = $t->walk(); - $this->assertEquals($html, stream_get_contents($stream, -1, 0)); - } + $stream = fopen('php://temp', 'w'); + $r = new OutputRules($stream, \HTML5::options()); + $t = new Traverser($dom, $stream, $r, \HTML5::options()); + + $out = $t->walk(); + $this->assertEquals($html, stream_get_contents($stream, -1, 0)); + } } -- cgit v1.2.3 From 51afaed4bad68a56c1719b89156f1fd80bdc7e44 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Wed, 6 Nov 2013 07:35:21 -0500 Subject: Improved test coverage. This caused a bug in processor instructions to appear. Fix them so they actually work now. --- RELEASE.md | 2 ++ src/HTML5/Parser/DOMTreeBuilder.php | 2 +- test/HTML5/Parser/DOMTreeBuilderTest.php | 39 ++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/RELEASE.md b/RELEASE.md index c85c65d..96b8127 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -4,6 +4,8 @@ - CDATA encoding is improved. (Non-standard; Issue #19) - Some parser rules were not returning the new current element. (Issue #20) - Added, to the README, details on code test coverage and to packagist version. +- Fixed processor instructions. +- Improved test coverage. 1.0.0 (2013-10-02) - Initial release. diff --git a/src/HTML5/Parser/DOMTreeBuilder.php b/src/HTML5/Parser/DOMTreeBuilder.php index 094104e..c28b436 100644 --- a/src/HTML5/Parser/DOMTreeBuilder.php +++ b/src/HTML5/Parser/DOMTreeBuilder.php @@ -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/test/HTML5/Parser/DOMTreeBuilderTest.php b/test/HTML5/Parser/DOMTreeBuilderTest.php index adfc2c9..0adaed5 100644 --- a/test/HTML5/Parser/DOMTreeBuilderTest.php +++ b/test/HTML5/Parser/DOMTreeBuilderTest.php @@ -301,6 +301,14 @@ class DOMTreeBuilderTest extends \HTML5\Tests\TestCase { $this->assertEquals('textPath', $textPath->tagName); } + public function testNoScript() { + $html = ''; + $doc = $this->parse($html); + $this->assertEmpty($doc->errors); + $noscript = $doc->getElementsByTagName('noscript')->item(0); + $this->assertEquals('noscript', $noscript->tagName); + } + /** * Regression for issue #13 */ @@ -314,4 +322,35 @@ class DOMTreeBuilderTest extends \HTML5\Tests\TestCase { $this->assertEquals('span', $span->tagName); $this->assertEquals('Test', $span->textContent); } + + public function testInstructionProcessor() { + $string = ''; + + $treeBuilder = new DOMTreeBuilder(); + $is = new InstructionProcessorMock(); + $treeBuilder->setInstructionProcessor($is); + + $input = new StringInputStream($string); + $scanner = new Scanner($input); + $parser = new Tokenizer($scanner, $treeBuilder); + + $parser->parse(); + + $this->assertEquals(1, $is->count); + $this->assertEquals('foo', $is->name); + $this->assertEquals('bar ', $is->data); + } +} + +class InstructionProcessorMock implements \HTML5\InstructionProcessor { + + public $name = NULL; + public $data = NULL; + public $count = 0; + + public function process(\DOMElement $element, $name, $data) { + $this->name = $name; + $this->data = $data; + $this->count++; + } } -- cgit v1.2.3 From c7095e630d1da8e3d25905ababea0808ad3d8f12 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Wed, 6 Nov 2013 07:56:35 -0500 Subject: Improving the documentation coverage. --- src/HTML5.php | 25 ++++++++++++++++++++++--- src/HTML5/Elements.php | 11 +++++++++-- src/HTML5/Parser/StringInputStream.php | 3 +++ 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/HTML5.php b/src/HTML5.php index ce0927f..7295fb4 100644 --- a/src/HTML5.php +++ b/src/HTML5.php @@ -1,5 +1,7 @@ document(); } + /** + * Parse an input stream where the stream is a fragment. + * + * Lower-level loading function. This requires an input stream instead + * of a string, file, or resource. + */ public static function parseFragment(\HTML5\Parser\InputStream $input) { $events = new DOMTreeBuilder(TRUE); $scanner = new Scanner($input); 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 @@ Date: Wed, 6 Nov 2013 08:04:33 -0500 Subject: Added phpdoc to composer require-dev so we can generate docs. --- RELEASE.md | 2 +- composer.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index 96b8127..2fed5f6 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -5,7 +5,7 @@ - Some parser rules were not returning the new current element. (Issue #20) - Added, to the README, details on code test coverage and to packagist version. - Fixed processor instructions. -- Improved test coverage. +- Improved test coverage and documentation coverage. 1.0.0 (2013-10-02) - Initial release. diff --git a/composer.json b/composer.json index a9dbc42..6b88b8a 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,8 @@ }, "require-dev": { "satooshi/php-coveralls": "0.6.*", - "phpunit/phpunit" : "*" + "phpunit/phpunit" : "*", + "phpdocumentor/phpdocumentor": "2.1.*" }, "autoload": { "psr-0": {"HTML5": "src"} -- cgit v1.2.3 From 25ad20463cf0fe25f7fda8bce0d5692d8d1c33d7 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Wed, 6 Nov 2013 10:40:30 -0500 Subject: Adding html5 entities autogenerated lookup list for PHP 5.3 to code coverage blacklist. --- phpunit.xml.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 9f840dd..c145f8b 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -10,6 +10,7 @@ src/HTML5/Parser/InputStream.php src/HTML5/Serializer/RulesInterface.php src/HTML5/Entities.php + src/HTML5/Serializer/HTML5Entities.php -- cgit v1.2.3 From af20c4d0d11e8d76a5840ae5973bc1e8735d5aaa Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Wed, 6 Nov 2013 19:58:27 -0500 Subject: Cleaning up the sarcasm tag parsing. --- src/HTML5/Parser/DOMTreeBuilder.php | 5 ----- test/HTML5/Html5Test.php | 4 +++- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/HTML5/Parser/DOMTreeBuilder.php b/src/HTML5/Parser/DOMTreeBuilder.php index c28b436..6dbd25e 100644 --- a/src/HTML5/Parser/DOMTreeBuilder.php +++ b/src/HTML5/Parser/DOMTreeBuilder.php @@ -318,11 +318,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) { diff --git a/test/HTML5/Html5Test.php b/test/HTML5/Html5Test.php index 1d3d7ab..4e7c300 100644 --- a/test/HTML5/Html5Test.php +++ b/test/HTML5/Html5Test.php @@ -201,11 +201,13 @@ class Html5Test extends TestCase { Big rectangle thing 40 80 - "); + + um, yeah"); $this->assertEmpty($dom->errors); $markup = \HTML5::saveHTML($dom); $this->assertRegExp('|Big rectangle thing|',$markup); + $this->assertRegExp('|um, yeah|',$markup); } public function testElements() { -- cgit v1.2.3 From 59ea1beeeec84637591737fa2efb192772a8a873 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Wed, 6 Nov 2013 21:16:16 -0500 Subject: Added instruction processor tests that do something interesting and useful as an example --- test/HTML5/Parser/DOMTreeBuilderTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/HTML5/Parser/DOMTreeBuilderTest.php b/test/HTML5/Parser/DOMTreeBuilderTest.php index 0adaed5..6eeafe8 100644 --- a/test/HTML5/Parser/DOMTreeBuilderTest.php +++ b/test/HTML5/Parser/DOMTreeBuilderTest.php @@ -335,10 +335,14 @@ class DOMTreeBuilderTest extends \HTML5\Tests\TestCase { $parser = new Tokenizer($scanner, $treeBuilder); $parser->parse(); + $dom = $treeBuilder->document(); + $div = $dom->getElementsByTagName('div')->item(0); $this->assertEquals(1, $is->count); $this->assertEquals('foo', $is->name); $this->assertEquals('bar ', $is->data); + $this->assertEquals('div', $div->tagName); + $this->assertEquals('foo', $div->textContent); } } @@ -352,5 +356,12 @@ class InstructionProcessorMock implements \HTML5\InstructionProcessor { $this->name = $name; $this->data = $data; $this->count++; + + $div = $element->ownerDocument->createElement("div"); + $div->nodeValue = 'foo'; + + $element->appendChild($div); + + return $div; } } -- cgit v1.2.3 From 176c8593729313f6d8ab710271fe354b92f7e1b4 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Thu, 7 Nov 2013 07:57:26 -0500 Subject: Updated the release notes for 1.0.1 --- RELEASE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE.md b/RELEASE.md index 2fed5f6..7f12702 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,6 +1,6 @@ # Release Notes -1.0.1 (unreleased) +1.0.1 (2013-11-07) - CDATA encoding is improved. (Non-standard; Issue #19) - Some parser rules were not returning the new current element. (Issue #20) - Added, to the README, details on code test coverage and to packagist version. -- cgit v1.2.3 From fbc3c7e214a4bbbc9e88eb574414a91a0faa2176 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Thu, 14 Nov 2013 18:46:56 -0500 Subject: There were 2 script lines and the second was not the one we wanted. Down to just the travis config we need. --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index aaf85dc..6b33aae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,4 @@ script: - phpunit -c phpunit.xml.dist after_script: - - php vendor/bin/coveralls -v - -script: phpunit test/HTML5 \ No newline at end of file + - php vendor/bin/coveralls -v \ No newline at end of file -- cgit v1.2.3 From c34046f30889823a72fa69e5fa015fdbb1a22929 Mon Sep 17 00:00:00 2001 From: Asmir Mustafic Date: Mon, 3 Feb 2014 15:01:43 +0100 Subject: Update Tokenizer.php Newlines and tabs are allowed inside quoted attributes --- src/HTML5/Parser/Tokenizer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HTML5/Parser/Tokenizer.php b/src/HTML5/Parser/Tokenizer.php index 1fd1d25..f81f069 100644 --- a/src/HTML5/Parser/Tokenizer.php +++ b/src/HTML5/Parser/Tokenizer.php @@ -460,7 +460,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) { -- cgit v1.2.3 From d4b0222f622f3deb67d1c7366edc7f0a0aae9523 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Fri, 7 Feb 2014 23:07:32 -0500 Subject: #26: Updated the case handling for tags to allow for uppercase tags and normalizing tag names to lowercase (per 8.2.4.9) except for SVG foreign tags that are case sensitive. --- src/HTML5/Parser/DOMTreeBuilder.php | 9 +++++++-- src/HTML5/Parser/Tokenizer.php | 4 ++-- test/HTML5/Html5Test.php | 2 +- test/HTML5/Parser/TokenizerTest.php | 8 +++++++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/HTML5/Parser/DOMTreeBuilder.php b/src/HTML5/Parser/DOMTreeBuilder.php index 6dbd25e..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) { diff --git a/src/HTML5/Parser/Tokenizer.php b/src/HTML5/Parser/Tokenizer.php index f81f069..04baa10 100644 --- a/src/HTML5/Parser/Tokenizer.php +++ b/src/HTML5/Parser/Tokenizer.php @@ -295,7 +295,7 @@ class Tokenizer { return $this->bogusComment('scanner->charsUntil("\n\f \t>"); + $name = strtolower($this->scanner->charsUntil("\n\f \t>")); // Trash whitespace. $this->scanner->whitespace(); @@ -831,7 +831,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/test/HTML5/Html5Test.php b/test/HTML5/Html5Test.php index 4e7c300..dcb51cd 100644 --- a/test/HTML5/Html5Test.php +++ b/test/HTML5/Html5Test.php @@ -134,7 +134,7 @@ class Html5Test extends TestCase { '); - $this->assertEmpty($dom->errors); + $this->assertEmpty($dom->errors, print_r($dom->errors, TRUE)); // Test a mixed case attribute. $list = $dom->getElementsByTagName('svg'); diff --git a/test/HTML5/Parser/TokenizerTest.php b/test/HTML5/Parser/TokenizerTest.php index edc427c..9f335b0 100644 --- a/test/HTML5/Parser/TokenizerTest.php +++ b/test/HTML5/Parser/TokenizerTest.php @@ -142,7 +142,7 @@ class TokenizerTest extends \HTML5\Tests\TestCase { '' => 'test', '' => - 'thisIsTheTagThatDoesntEndItJustGoesOnAndOnMyFriend', + 'thisisthetagthatdoesntenditjustgoesonandonmyfriend', // See 8.2.4.10, which requires this and does not say error. '' => 'aassertEventEquals('text', $expects, $events->get(2)); } + // Testing case sensitivity + $events = $this->parse('a test'); + $this->assertEventEquals('startTag', 'title', $events->get(0)); + $this->assertEventEquals('text', 'a test', $events->get(1)); + $this->assertEventEquals('endTag', 'title', $events->get(2)); + } public function testText() { -- cgit v1.2.3 From 3b691837c6d7a0969137048fbda274463d6b1d7c Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Mon, 10 Feb 2014 20:50:30 -0500 Subject: Added Asmir Mustafic to the credits and re-organized the file to alpha ordering for contributors. --- CREDITS | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CREDITS b/CREDITS index 193bc34..1f805e6 100644 --- a/CREDITS +++ b/CREDITS @@ -1,6 +1,7 @@ Matt Butcher [technosophos] (lead) Matt Farina [mattfarina] (lead) -Kukhar Vasily [ngreduce] (contributor) -Geoffrey Sneddon [gsnedders] (contributor) +Asmir Mustafic [goetas] (contributor) Edward Z. Yang [ezyang] (contributor) +Geoffrey Sneddon [gsnedders] (contributor) +Kukhar Vasily [ngreduce] (contributor) Rune Christensen [MrElectronic] (contributor) -- cgit v1.2.3