mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Fix whitespace trimming for soft and hard breaks
This commit is contained in:
parent
0626a83289
commit
c2973100e0
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -1,2 +1,8 @@
|
||||
<p>line<br />
|
||||
line</p>
|
||||
line</p>
|
||||
<p>foo \
|
||||
bar</p>
|
||||
<p>foo <br />
|
||||
bar</p>
|
||||
<p>foo
|
||||
bar</p>
|
@ -1,2 +1,11 @@
|
||||
line
|
||||
line
|
||||
line
|
||||
|
||||
foo \\
|
||||
bar
|
||||
|
||||
foo \
|
||||
bar
|
||||
|
||||
foo
|
||||
bar
|
Loading…
Reference in New Issue
Block a user