@Override public BlockStart tryStart(ParserState state, MatchedBlockParser matchedBlockParser) { int nextNonSpace = state.getNextNonSpaceIndex(); BasedSequence line = state.getLine(); Matcher matcher; if (state.getIndent() < 4) { BasedSequence trySequence = line.subSequence(nextNonSpace, line.length()); if ((matcher = OPENING_FENCE.matcher(trySequence)).find()) { int fenceLength = matcher.group(0).length(); char fenceChar = matcher.group(0).charAt(0); FencedCodeBlockParser blockParser = new FencedCodeBlockParser(state.getProperties(), fenceChar, fenceLength, state.getIndent(), nextNonSpace); blockParser.block.setOpeningMarker(trySequence.subSequence(0, fenceLength)); return BlockStart.of(blockParser).atIndex(nextNonSpace + fenceLength); } } return BlockStart.none(); } }
@Override public boolean canContain(ParserState state, BlockParser blockParser, Block block) { // Issue 66, fenced code can only be contained in GitHub Doc mode if it is indented more than list item if (block instanceof FencedCodeBlock) { // see if it indented more than our marker if (state.getProperties().get(PARSER_EMULATION_PROFILE) == GITHUB_DOC) { // Issue #66, if we are in a list item and our indent == list indent then we interrupt the list FencedCodeBlockParser parser = (FencedCodeBlockParser)blockParser; return myListData.markerIndent < parser.getFenceMarkerIndent(); } } return true; }
@Override public boolean canContain(ParserState state, BlockParser blockParser, Block block) { // Issue 66, fenced code can only be contained in GitHub Doc mode if it is indented more than list item if (block instanceof FencedCodeBlock) { // see if it indented more than our marker if (state.getProperties().get(PARSER_EMULATION_PROFILE) == GITHUB_DOC) { // Issue #66, if we are in a list item and our indent == list indent then we interrupt the list FencedCodeBlockParser parser = (FencedCodeBlockParser)blockParser; return myListData.markerIndent < parser.getFenceMarkerIndent(); } } return true; }
@Override public BlockStart tryStart(ParserState state, MatchedBlockParser matchedBlockParser) { int nextNonSpace = state.getNextNonSpaceIndex(); BasedSequence line = state.getLine(); Matcher matcher; if (state.getIndent() < 4) { BasedSequence trySequence = line.subSequence(nextNonSpace, line.length()); if ((matcher = OPENING_FENCE.matcher(trySequence)).find()) { int fenceLength = matcher.group(0).length(); char fenceChar = matcher.group(0).charAt(0); FencedCodeBlockParser blockParser = new FencedCodeBlockParser(state.getProperties(), fenceChar, fenceLength, state.getIndent(), nextNonSpace); blockParser.block.setOpeningMarker(trySequence.subSequence(0, fenceLength)); return BlockStart.of(blockParser).atIndex(nextNonSpace + fenceLength); } } return BlockStart.none(); } }