Skip to content

Commit

Permalink
Don't allow list items that are indented >= 4 spaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
colinodell committed Mar 24, 2019
1 parent 96261f4 commit 36eca58
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Block/Parser/ListParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,25 @@ public function parse(ContextInterface $context, Cursor $cursor): bool
return false;
}

$indent = $cursor->getIndent();
if ($indent >= 4) {
return false;
}

$tmpCursor = clone $cursor;
$tmpCursor->advanceToNextNonSpaceOrTab();
$rest = $tmpCursor->getRemainder();

if (\preg_match('/^[*+-]/', $rest) === 1) {
$data = new ListData();
$data->markerOffset = $cursor->getIndent();
$data->markerOffset = $indent;
$data->type = ListBlock::TYPE_UNORDERED;
$data->delimiter = null;
$data->bulletChar = $rest[0];
$markerLength = 1;
} elseif (($matches = RegexHelper::matchAll('/^(\d{1,9})([.)])/', $rest)) && (!($context->getContainer() instanceof Paragraph) || $matches[1] === '1')) {
$data = new ListData();
$data->markerOffset = $cursor->getIndent();
$data->markerOffset = $indent;
$data->type = ListBlock::TYPE_ORDERED;
$data->start = (int) $matches[1];
$data->delimiter = $matches[2];
Expand Down

0 comments on commit 36eca58

Please sign in to comment.