mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Ensure marker is properly contained in the Inline
This commit is contained in:
parent
dbe37bcb0e
commit
b90efc69ec
@ -201,15 +201,19 @@ final class Parsedown
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$markerPosition = $Excerpt->offset();
|
||||||
$startPosition = $Inline->modifyStartPositionTo();
|
$startPosition = $Inline->modifyStartPositionTo();
|
||||||
|
|
||||||
if (! isset($startPosition)) {
|
if (! isset($startPosition)) {
|
||||||
$startPosition = $Excerpt->offset();
|
$startPosition = $markerPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
# makes sure that the inline belongs to "our" marker
|
$endPosition = $startPosition + $Inline->width();
|
||||||
|
|
||||||
if ($startPosition > $Excerpt->offset() || $startPosition < 0) {
|
if ($startPosition > $markerPosition
|
||||||
|
|| $endPosition < $markerPosition
|
||||||
|
|| $startPosition < 0
|
||||||
|
) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +226,7 @@ final class Parsedown
|
|||||||
|
|
||||||
# remove the examined text
|
# remove the examined text
|
||||||
/** @psalm-suppress LoopInvalidation */
|
/** @psalm-suppress LoopInvalidation */
|
||||||
$Excerpt = $Excerpt->choppingFromOffset($startPosition + $Inline->width());
|
$Excerpt = $Excerpt->choppingFromOffset($endPosition);
|
||||||
|
|
||||||
continue 2;
|
continue 2;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user