Skip to content

Commit

Permalink
Cleanup after latest PR
Browse files Browse the repository at this point in the history
  • Loading branch information
j0k3r committed Jun 8, 2018
1 parent 4ab3b31 commit ed87be6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Graby.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ private function doFetchContent($url)
}

$html = $this->convert2Utf8($response['body'], $response['all_headers']);
// Removing empty nodes

// Remove empty nodes (except iframe)
$re = '/<([^>\s]+)[^iframe|>]*>(?:\s*(?:<br \/>|&nbsp;|&thinsp;|&ensp;|&emsp;|&#8201;|&#8194;|&#8195;)\s*)*<\/\1>/m';
$html = preg_replace($re, '', $html);

Expand Down
3 changes: 2 additions & 1 deletion tests/GrabyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1444,13 +1444,14 @@ public function testEmptyNodesRemoved()
[
'content-type' => 'text/html',
],
Stream::factory(file_get_contents(__DIR__ . '/fixtures/sites/framablog.test'))
Stream::factory(__DIR__ . '/fixtures/sites/framablog.test')
);
$client = new Client();
$client->getEmitter()->attach(new Mock([$response]));

$graby = new Graby();
$res = $graby->fetchContent('https://framablog.org/2017/12/02/avancer-ensemble-vers-la-contribution/');

// The initial treatment was encapsulating the content into the empty node
// So we don't want to see that again
$this->assertNotContains('<figure><p>Après un <em>icebreaker</em>', $res['html']);
Expand Down

0 comments on commit ed87be6

Please sign in to comment.