From 13932bca9a40a7569ec3b84f6cf534b726f96dac Mon Sep 17 00:00:00 2001 From: Aidan Woods Date: Sun, 19 Jan 2020 15:09:44 +0000 Subject: [PATCH] Simplify match logic --- src/Components/Blocks/TList.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Components/Blocks/TList.php b/src/Components/Blocks/TList.php index d45c5fd..8c8a532 100644 --- a/src/Components/Blocks/TList.php +++ b/src/Components/Blocks/TList.php @@ -173,14 +173,14 @@ final class TList implements ContinuableBlock $Lis = $this->Lis; + if ($this->type === 'ol') { + $regex = '/^([0-9]++'.$this->markerTypeRegex.')([\t ]++.*|$)/'; + } else { + $regex = '/^('.$this->markerTypeRegex.')([\t ]++.*|$)/'; + } + if ($Context->line()->indent() < $requiredIndent - && (( - $this->type === 'ol' - && \preg_match('/^([0-9]++'.$this->markerTypeRegex.')([\t ]++.*|$)/', $Context->line()->text(), $matches) - ) || ( - $this->type === 'ul' - && \preg_match('/^('.$this->markerTypeRegex.')([\t ]++.*|$)/', $Context->line()->text(), $matches) - )) + && \preg_match($regex, $Context->line()->text(), $matches) ) { if ($Context->previousEmptyLines() > 0) { $Lis[\count($Lis) -1] = $Lis[\count($Lis) -1]->appendingBlankLines(1);