From 5a50930cb0802a7ec8d46298c925515dec3c8abd Mon Sep 17 00:00:00 2001 From: Aidan Woods Date: Fri, 25 Jan 2019 19:02:30 +0000 Subject: [PATCH] Allow inlines to backtrack into characters that were suspected as inlines but ruled out This is required for backslash escaped Hard breaks to work: Parsedown first checks to see if these are escape sequences, however when they are ruled out they should not be assumed to be plaintext since a later inline (Hardbreak) may backtrack into these unconsumed characters. --- src/Parsedown.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/Parsedown.php b/src/Parsedown.php index 84822a8..44f1cee 100644 --- a/src/Parsedown.php +++ b/src/Parsedown.php @@ -306,16 +306,8 @@ final class Parsedown continue 2; } - if (! isset($startPosition)) { - $startPosition = $Excerpt->offset(); - } - - # the marker does not belong to an inline - - $Inlines[] = Plaintext::build($Excerpt->choppingUpToOffset($startPosition + 1)); - /** @psalm-suppress LoopInvalidation */ - $Excerpt = $Excerpt->choppingFromOffset($startPosition + 1); + $Excerpt = $Excerpt->addingToOffset(1); } $Inlines[] = Plaintext::build($Excerpt->choppingFromOffset(0));