Skip to content

trim whitespace from HTML value as well #139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Mf2/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ public function parseE(\DOMElement $e) {
}

$return = array(
'html' => $html,
'html' => unicodeTrim($html),
'value' => unicodeTrim($this->innerText($e)),
);

Expand Down
14 changes: 14 additions & 0 deletions tests/Mf2/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,20 @@ public function testParseEWithBR() {
$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']);
}

public function testParseEWithWhitespace() {
$input = '<div class="h-entry">
<div class="e-content">
This <strong>leading and trailing whitespace</strong> should be removed from the HTML and text values.
</div>
</div>';
//$parser = new Parser($input);
$output = Mf2\parse($input);

$this->assertArrayHasKey('content', $output['items'][0]['properties']);
$this->assertEquals('This <strong>leading and trailing whitespace</strong> should be removed from the HTML and text values.', $output['items'][0]['properties']['content'][0]['html']);
$this->assertEquals('This leading and trailing whitespace should be removed from the HTML and text values.', $output['items'][0]['properties']['content'][0]['value']);
}

/**
* @group parseH
*/
Expand Down