BlockFactory(DataHolder options) { super(options); this.options = new HeadingOptions(options); this.myParsing = new HeadingParsing(options); }
@Override public BlockParserFactory create(DataHolder options) { return new BlockFactory(options); } }
@Override public BlockParserFactory create(DataHolder options) { return new BlockFactory(options); } }
@Override public MutableDataHolder getProperties() { return documentBlockParser.getBlock(); }
@Override public void closeBlock(ParserState state) { finalizeListTight(state); if (state.getProperties().get(BLANK_LINES_IN_AST)) { // need to transfer trailing blank line nodes from last item to parent list ListBlock block = getBlock(); Node child = block.getFirstChildAnyNot(BlankLine.class); while (child instanceof ListItem) { // transfer its trailing blank lines to us child.moveTrailingBlankLines(); child = child.getNextAnyNot(BlankLine.class); } } myBlock.setCharsFromContentOnly(); }
public BlockStart tryStart(ParserState state, MatchedBlockParser matchedBlockParser) { int nextNonSpace = state.getNextNonSpaceIndex(); BlockParser matched = matchedBlockParser.getBlockParser(); boolean inParagraph = matched.isParagraphParser(); boolean inParagraphListItem = inParagraph && matched.getBlock().getParent() instanceof ListItem && matched.getBlock() == matched.getBlock().getParent().getFirstChild(); if (isMarker(state, nextNonSpace, inParagraph, inParagraphListItem, allowLeadingSpace, interruptsParagraph, interruptsItemParagraph, withLeadSpacesInterruptsItemParagraph)) { int newColumn = state.getColumn() + state.getIndent() + 1; // optional following space or tab if (Parsing.isSpaceOrTab(state.getLine(), nextNonSpace + 1)) { newColumn++; } return BlockStart.of(new BlockQuoteParser(state.getProperties(), state.getLine().subSequence(nextNonSpace, nextNonSpace + 1))).atColumn(newColumn); } else { return BlockStart.none(); } } }
@Override public BlockParserFactory create(DataHolder options) { return new BlockFactory(options); } }
@Override public BlockParserFactory create(DataHolder options) { return new BlockFactory(options); } }
@Override public BlockParserFactory create(DataHolder options) { return new BlockFactory(options); } }
@Override public BlockParserFactory create(DataHolder options) { return new BlockFactory(options); } }
@Override public BlockParserFactory create(DataHolder options) { return new BlockFactory(options); } }
private BlockFactory(DataHolder options) { super(options); this.options = new ThematicBreakOptions(options); }
int getLastContentIndent() { return myLastChild.getContentIndent(); }
@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 void closeBlock(ParserState state) { block.setCharsFromContent(); if (!state.getProperties().get(Parser.BLANK_LINES_IN_AST)) { removeBlankLines(); } }
@Override public BlockStart tryStart(ParserState state, MatchedBlockParser matchedBlockParser) { // An indented code block cannot interrupt a paragraph. if (state.getIndent() >= state.getParsing().CODE_BLOCK_INDENT && !state.isBlank() && !(state.getActiveBlockParser().getBlock() instanceof Paragraph)) { return BlockStart.of(new IndentedCodeBlockParser(state.getProperties())).atColumn(state.getColumn() + state.getParsing().CODE_BLOCK_INDENT); } else { return BlockStart.none(); } } }
@Override public BlockStart tryStart(ParserState state, MatchedBlockParser matchedBlockParser) { if (state.getIndent() >= 4 || matchedBlockParser.getBlockParser().isParagraphParser() && !options.relaxedStart) { return BlockStart.none(); } BasedSequence line = state.getLine(); final BasedSequence input = line.subSequence(state.getNextNonSpaceIndex(), line.length()); if (PATTERN.matcher(input).matches()) { return BlockStart.of(new ThematicBreakParser(line.subSequence(state.getIndex()))).atIndex(line.length()); } else { return BlockStart.none(); } } }
@Override public BlockContinue tryContinue(ParserState state) { int nextNonSpace = state.getNextNonSpaceIndex(); boolean isMarker; if (!state.isBlank() && ((isMarker = isMarker(state, nextNonSpace, false, false, allowLeadingSpace, interruptsParagraph, interruptsItemParagraph, withLeadSpacesInterruptsItemParagraph)) || (continueToBlankLine && lastWasBlankLine == 0))) { int newColumn = state.getColumn() + state.getIndent(); lastWasBlankLine = 0; if (isMarker) { newColumn++; // optional following space or tab if (Parsing.isSpaceOrTab(state.getLine(), nextNonSpace + 1)) { newColumn++; } } return BlockContinue.atColumn(newColumn); } else { if (ignoreBlankLine && state.isBlank()) { lastWasBlankLine++; int newColumn = state.getColumn() + state.getIndent(); return BlockContinue.atColumn(newColumn); } return BlockContinue.none(); } }
Document document = this.documentBlockParser.getBlock(); inlineParser.finalizeDocument(document);