Java Code Examples for org.commonmark.parser.block.BlockContinue#none()

The following examples show how to use org.commonmark.parser.block.BlockContinue#none() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListItemParser.java    From 1Rramp-Android with MIT License 6 votes vote down vote up
@Override
public BlockContinue tryContinue(ParserState state) {
    if (state.isBlank()) {
        if (block.getFirstChild() == null) {
            // Blank line after empty list item
            return BlockContinue.none();
        } else {
            return BlockContinue.atIndex(state.getNextNonSpaceIndex());
        }
    }

    if (state.getIndent() >= contentIndent) {
        return BlockContinue.atColumn(state.getColumn() + contentIndent);
    } else {
        return BlockContinue.none();
    }
}
 
Example 2
Source File: TaskListBlockParser.java    From Markwon with Apache License 2.0 6 votes vote down vote up
@Override
public BlockContinue tryContinue(ParserState parserState) {

    final BlockContinue blockContinue;

    final String line = line(parserState);

    final int currentIndent = parserState.getIndent();
    if (currentIndent > indent) {
        indent += 2;
    } else if (currentIndent < indent && indent > 1) {
        indent -= 2;
    }

    if (line != null
            && line.length() > 0
            && PATTERN.matcher(line).matches()) {
        blockContinue = BlockContinue.atIndex(parserState.getIndex());
    } else {
        // @since 2.0.0, previously called `BlockContinue.finished()`
        //  that was swallowing non-matching lines
        blockContinue = BlockContinue.none();
    }

    return blockContinue;
}
 
Example 3
Source File: ListItemParser.java    From commonmark-java with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public BlockContinue tryContinue(ParserState state) {
    if (state.isBlank()) {
        if (block.getFirstChild() == null) {
            // Blank line after empty list item
            return BlockContinue.none();
        } else {
            Block activeBlock = state.getActiveBlockParser().getBlock();
            // If the active block is a code block, blank lines in it should not affect if the list is tight.
            hadBlankLine = activeBlock instanceof Paragraph || activeBlock instanceof ListItem;
            return BlockContinue.atIndex(state.getNextNonSpaceIndex());
        }
    }

    if (state.getIndent() >= contentIndent) {
        return BlockContinue.atColumn(state.getColumn() + contentIndent);
    } else {
        return BlockContinue.none();
    }
}
 
Example 4
Source File: ParagraphParser.java    From 1Rramp-Android with MIT License 5 votes vote down vote up
@Override
public BlockContinue tryContinue(ParserState state) {
    if (!state.isBlank()) {
        return BlockContinue.atIndex(state.getIndex());
    } else {
        return BlockContinue.none();
    }
}
 
Example 5
Source File: ParagraphParser.java    From commonmark-java with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public BlockContinue tryContinue(ParserState state) {
    if (!state.isBlank()) {
        return BlockContinue.atIndex(state.getIndex());
    } else {
        return BlockContinue.none();
    }
}
 
Example 6
Source File: TableBlockParser.java    From js-dossier with Apache License 2.0 5 votes vote down vote up
@Override
public BlockContinue tryContinue(ParserState state) {
  if (state.getLine().toString().contains("|")
      || CAPTION_LINE.matcher(state.getLine()).matches()) {
    return BlockContinue.atIndex(state.getIndex());
  } else {
    return BlockContinue.none();
  }
}