mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Ensure $startPosition is positive
This commit is contained in:
@@ -42,20 +42,12 @@ final class HardBreak implements Inline
|
||||
$context = $Excerpt->context();
|
||||
$offset = $Excerpt->offset();
|
||||
|
||||
if ($offset < 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (\substr($context, $offset -1, 1) === '\\') {
|
||||
$contentLen = $offset -1;
|
||||
|
||||
return new self($offset - $contentLen, $contentLen);
|
||||
}
|
||||
|
||||
if ($offset < 2) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (\substr($context, $offset -2, 2) === ' ') {
|
||||
$trimTrailingWhitespace = \rtrim(\substr($context, 0, $offset));
|
||||
$contentLen = \strlen($trimTrailingWhitespace);
|
||||
|
||||
Reference in New Issue
Block a user