mirror of
https://github.com/erusev/parsedown.git
synced 2025-09-05 20:33:03 +02:00
Fix whitespace trimming for soft and hard breaks
This commit is contained in:
@@ -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
|
Reference in New Issue
Block a user