From 0a43799da4f6b10d9fc3bdbb6482e2e1713fb79f Mon Sep 17 00:00:00 2001 From: Aidan Woods Date: Thu, 13 Oct 2016 14:29:52 +0100 Subject: [PATCH] Prevent failure with data set 77 in CommonMarkWeak --- Parsedown.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Parsedown.php b/Parsedown.php index 2ee841746..f774b886a 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -115,7 +115,7 @@ function setUrlsLinked($urlsLinked) # Blocks # - protected function lines(array $lines) + protected function lines(array $lines, $parentType = null) { $CurrentBlock = null; @@ -216,6 +216,12 @@ protected function lines(array $lines) $blockTypes = array_merge($highPriority, $blockTypes); + if ( $parentType === 'List' and ($a = array_search('List', $blockTypes)) !== false and ($b = array_search('Code', $blockTypes)) !== false and $a > $b and ($placeholder = $this->blockList($Line))) + { + unset($blockTypes[$b]); + array_splice($blockTypes, $a + 1, 0, 'Code'); + } + # # ~ @@ -1502,7 +1508,7 @@ protected function elements(array $Elements) protected function li($lines) { - $markup = $this->lines($lines); + $markup = $this->lines($lines, 'List'); $trimmedMarkup = trim($markup);