Skip to content

Commit 48fe89f

Browse files
authored
Merge pull request paquettg#75 from parisholley/whitespace
support html tags with extra whitespace
2 parents 8c150f5 + 9bc35db commit 48fe89f

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/PHPHtmlParser/Dom.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,8 @@ protected function parseTag()
516516
}
517517

518518
if (empty($name)) {
519-
$this->content->fastForward(1);
520-
continue;
519+
$this->content->skipByToken('blank');
520+
continue;
521521
}
522522

523523
$this->content->skipByToken('blank');

tests/DomTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,15 @@ public function testLoadUtf8()
172172
$this->assertEquals('Dzień', $dom->find('p', 0)->text);
173173
}
174174

175+
public function testLoadFileWhitespace()
176+
{
177+
$dom = new Dom;
178+
$dom->setOptions(['cleanupInput' => false]);
179+
$dom->loadFromFile('tests/files/whitespace.html');
180+
$this->assertEquals(1, count($dom->find('.class')));
181+
$this->assertEquals("<span><span class=\"class\"></span></span>", (string)$dom);
182+
}
183+
175184
public function testLoadFileBig()
176185
{
177186
$dom = new Dom;

tests/files/whitespace.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<span><span class="class" ></span></span>

0 commit comments

Comments
 (0)