From bd65bcfa65f958c7aae248b30c87df8b419fcad8 Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Sun, 17 Apr 2016 15:29:17 +0200 Subject: [PATCH] when parsing e-content, output result as HTML * adds failing test for parsing 'one
two' (currently converts it to 'one

two' * fixes parser by using saveHTML instead of C14N --- Mf2/Parser.php | 2 +- tests/Mf2/ParserTest.php | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Mf2/Parser.php b/Mf2/Parser.php index 6f8d129..3717c58 100644 --- a/Mf2/Parser.php +++ b/Mf2/Parser.php @@ -736,7 +736,7 @@ public function parseE(\DOMElement $e) { $html = ''; foreach ($e->childNodes as $node) { - $html .= $node->C14N(); + $html .= $node->ownerDocument->saveHTML($node); } return array( diff --git a/tests/Mf2/ParserTest.php b/tests/Mf2/ParserTest.php index cfc1d8a..30e59d9 100644 --- a/tests/Mf2/ParserTest.php +++ b/tests/Mf2/ParserTest.php @@ -92,10 +92,20 @@ public function testParseEResolvesRelativeLinks() { $parser = new Parser($input, 'http://example.com'); $output = $parser->parse(); - $this->assertEquals('Blah blah thing. ', $output['items'][0]['properties']['content'][0]['html']); + $this->assertEquals('Blah blah thing. ', $output['items'][0]['properties']['content'][0]['html']); $this->assertEquals('Blah blah thing. http://example.com/img', $output['items'][0]['properties']['content'][0]['value']); } + public function testParseEWithBR() { + $input = '
Here is content with two lines.
The br tag should not be converted to an XML br/br element.
'; + //$parser = new Parser($input); + $output = Mf2\parse($input); + + $this->assertArrayHasKey('content', $output['items'][0]['properties']); + $this->assertEquals('Here is content with two lines.
The br tag should not be converted to an XML br/br element.', $output['items'][0]['properties']['content'][0]['html']); + $this->assertEquals('Here is content with two lines.'."\n".'The br tag should not be converted to an XML br/br element.', $output['items'][0]['properties']['content'][0]['value']); + } + /** * @group parseH */