Skip to content

Commit af25da2

Browse files
committed
Remove "two blank lines breaks out of lists" feature (spec 0.26, #55)
1 parent 7a4a974 commit af25da2

1 file changed

Lines changed: 3 additions & 28 deletions

File tree

commonmark/src/main/java/org/commonmark/internal/DocumentParser.java

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,6 @@ private void incorporateLine(CharSequence ln) {
182182
BlockParser blockParser = lastMatchedBlockParser;
183183
boolean allClosed = unmatchedBlockParsers.isEmpty();
184184

185-
// Check to see if we've hit 2nd blank line; if so break out of list:
186-
if (isBlank() && isLastLineBlank(blockParser.getBlock())) {
187-
List<BlockParser> matchedBlockParsers = new ArrayList<>(activeBlockParsers.subList(0, matches));
188-
breakOutOfLists(matchedBlockParsers);
189-
}
190-
191185
// Unless last matched container is a code block, try new container starts,
192186
// adding children to the last matched container:
193187
boolean tryBlockStarts = blockParser.getBlock() instanceof Paragraph || blockParser.isContainer();
@@ -423,24 +417,6 @@ private boolean endsWithBlankLine(Node block) {
423417
return false;
424418
}
425419

426-
/**
427-
* Break out of all containing lists, resetting the tip of the document to the parent of the highest list,
428-
* and finalizing all the lists. (This is used to implement the "two blank lines break of of all lists" feature.)
429-
*/
430-
private void breakOutOfLists(List<BlockParser> blockParsers) {
431-
int lastList = -1;
432-
for (int i = blockParsers.size() - 1; i >= 0; i--) {
433-
BlockParser blockParser = blockParsers.get(i);
434-
if (blockParser instanceof ListBlockParser) {
435-
lastList = i;
436-
}
437-
}
438-
439-
if (lastList != -1) {
440-
finalizeBlocks(blockParsers.subList(lastList, blockParsers.size()));
441-
}
442-
}
443-
444420
/**
445421
* Add block of type tag as a child of the tip. If the tip can't accept children, close and finalize it and try
446422
* its parent, and so on til we find a block that can accept children.
@@ -480,10 +456,9 @@ private void propagateLastLineBlank(BlockParser blockParser, BlockParser lastMat
480456

481457
Block block = blockParser.getBlock();
482458

483-
// Block quote lines are never blank as they start with >
484-
// and we don't count blanks in fenced code for purposes of tight/loose
485-
// lists or breaking out of lists. We also don't set lastLineBlank
486-
// on an empty list item.
459+
// Block quote lines are never blank as they start with `>`.
460+
// We don't count blanks in fenced code for purposes of tight/loose lists.
461+
// We also don't set lastLineBlank on an empty list item.
487462
boolean lastLineBlank = isBlank() &&
488463
!(block instanceof BlockQuote ||
489464
block instanceof FencedCodeBlock ||

0 commit comments

Comments
 (0)