Fix whitespace trimming for soft and hard breaks

This commit is contained in:
Aidan Woods 2019-02-03 01:25:01 +00:00
parent 0626a83289
commit c2973100e0
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9
4 changed files with 20 additions and 6 deletions

View File

@ -41,8 +41,7 @@ final class HardBreak implements Inline
}
if (\substr($context, $offset -1, 1) === '\\') {
$trimTrailingWhitespace = \rtrim(\substr($context, 0, $offset -1));
$contentLen = \strlen($trimTrailingWhitespace);
$contentLen = $offset -1;
return new self($offset - $contentLen, $contentLen);
}

View File

@ -39,8 +39,8 @@ final class SoftBreak implements Inline
$context = $Excerpt->context();
$offset = $Excerpt->offset();
$trimTrailingWhitespaceBefore = \rtrim(\substr($context, 0, $offset));
$trimLeadingWhitespaceAfter = \ltrim(\substr($context, $offset + 1));
$trimTrailingWhitespaceBefore = \rtrim(\substr($context, 0, $offset), ' ');
$trimLeadingWhitespaceAfter = \ltrim(\substr($context, $offset + 1), ' ');
$contentLenBefore = \strlen($trimTrailingWhitespaceBefore);
$contentLenAfter = \strlen($trimLeadingWhitespaceAfter);

View File

@ -1,2 +1,8 @@
<p>line<br />
line</p>
<p>foo \
bar</p>
<p>foo <br />
bar</p>
<p>foo
bar</p>

View File

@ -1,2 +1,11 @@
line
line
foo \\
bar
foo \
bar
foo
bar