Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,9 @@ private void parseLine(CharSequence ln) {

BlockStartImpl blockStart = findBlockStart(blockParser);
if (blockStart == null) {
setNewIndex(nextNonSpace);
if (!blockParserFactories.isEmpty()) {
setNewIndex(nextNonSpace);
}
break;
}

Expand Down
29 changes: 29 additions & 0 deletions commonmark/src/test/java/org/commonmark/test/ParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,35 @@ public void indentation() {
assertEquals("tab + space", firstText(list.getFirstChild().getNext()));
}

@Test
public void indentationInParagraph() {
String given = " - 1 space\n - 3 spaces\n - 5 spaces\n\t - tab + space";
Parser parser = Parser.builder()
.enabledBlockTypes(new HashSet<Class<? extends Block>>())
.build();
Node document = parser.parse(given);

assertThat(document.getFirstChild(), instanceOf(Paragraph.class));

Node list = document.getFirstChild();
Node firstChild = list.getFirstChild(); // first item
assertEquals(" - 1 space", firstText(firstChild));

Node secondChild = firstChild.getNext(); // second item
assertThat(secondChild, instanceOf(SoftLineBreak.class));
assertEquals(" - 3 spaces", firstText(secondChild.getNext()));

Node fourthChild = secondChild.getNext().getNext();
assertThat(fourthChild, instanceOf(SoftLineBreak.class));

assertEquals(" - 5 spaces", firstText(fourthChild.getNext()));

Node sixthChild = fourthChild.getNext().getNext();
assertThat(sixthChild, instanceOf(SoftLineBreak.class));

assertEquals("\t - tab + space", firstText(sixthChild.getNext()));
}

@Test
public void inlineParser() {
final InlineParser fakeInlineParser = new InlineParser() {
Expand Down