@Override public BlockContinue tryContinue(ParserState state) { // List blocks themselves don't have any markers, only list items. So try to stay in the list. // If there is a block start other than list item, canContain makes sure that this list is closed. return BlockContinue.atIndex(state.getIndex()); }
@Override public BlockContinue tryContinue(ParserState state) { return BlockContinue.atIndex(state.getIndex()); }
@Override public BlockContinue tryContinue(ParserState state) { if (state.getLine().toString().contains("|")) { return BlockContinue.atIndex(state.getIndex()); } else { return BlockContinue.none(); } }
@Override public BlockContinue tryContinue(ParserState state) { if (ZZZZZZ_BLOCK_CONTINUE.matcher(state.getLine()).matches()) { return BlockContinue.atIndex(state.getIndex()); } else { return BlockContinue.none(); } }
@Override public BlockContinue tryContinue(ParserState state) { final BasedSequence line = state.getLine(); if (inYAMLBlock) { Matcher matcher = JEKYLL_FRONT_MATTER_BLOCK_END.matcher(line); if (matcher.matches()) { block.setClosingMarker(line.subSequence(matcher.start(1), matcher.end(1))); return BlockContinue.finished(); } return BlockContinue.atIndex(state.getIndex()); } else if (JEKYLL_FRONT_MATTER_BLOCK_START.matcher(line).matches()) { inYAMLBlock = true; return BlockContinue.atIndex(state.getIndex()); } return BlockContinue.none(); }
@Override public BlockStart tryStart(ParserState state, MatchedBlockParser matchedBlockParser) { BasedSequence line = state.getLine(); List<BasedSequence> paragraphLines = matchedBlockParser.getParagraphLines(); if (paragraphLines != null && paragraphLines.size() >= 1 && paragraphLines.size() <= maxHeaderRows && paragraphLines.get(0).toString().contains("|")) { BasedSequence separatorLine = line.subSequence(state.getIndex(), line.length()); if (TABLE_HEADER_SEPARATOR.matcher(separatorLine).matches()) { BasedSequence paragraph = paragraphLines.get(0); List<BasedSequence> headParts = split(paragraph); List<BasedSequence> separatorParts = split(separatorLine); if (separatorParts.size() >= headParts.size()) { TableBlockParser tableBlockParser = new TableBlockParser(); tableBlockParser.addLine(state, paragraph); tableBlockParser.nextIsSeparatorLine = true; return BlockStart.of(tableBlockParser) .atIndex(state.getIndex()) .replaceActiveBlockParser(); } } } return BlockStart.none(); } }
@Override public BlockStart tryStart(ParserState state, MatchedBlockParser matchedBlockParser) { BasedSequence line = state.getLine(); if (ZZZZZZ_BLOCK_START.matcher(line).matches()) { return BlockStart.of(new ZzzzzzBlockParser(state.getProperties())) .atIndex(state.getIndex()) //.replaceActiveBlockParser() ; } return BlockStart.none(); } }
@Override public BlockContinue tryContinue(ParserState state) { if (!state.isBlank()) { return BlockContinue.atIndex(state.getIndex()); } else { block.setTrailingBlankLine(true); return BlockContinue.none(); } }
@Override public BlockStart tryStart(ParserState state, MatchedBlockParser matchedBlockParser) { if (state.getIndex() == 0 && !haveBlockQuoteParser(state)) { BasedSequence line = state.getLineWithEOL(); final Matcher matcher = (state.getParsing().intellijDummyIdentifier ? MACRO_BLOCK_START_INTELLIJ : MACRO_BLOCK_START).matcher(line); if (matcher.matches()) { return BlockStart.of(new MacroDefinitionBlockParser(state.getProperties(), line.subSequence(0, 3), line.subSequence(matcher.start(1), matcher.end(1)), line.subSequence(matcher.start(2), matcher.end(1)))) .atIndex(state.getLineEndIndex()) //.replaceActiveBlockParser() ; } } return BlockStart.none(); } }
@Override public BlockContinue tryContinue(ParserState state) { // we stop on a blank line if blank line spacer is not enabled or we already had one if ((!options.isBlankLineSpacer || haveChildren != 0) && state.isBlank()) { return BlockContinue.none(); } else { if (state.isBlank()) { haveChildren |= HAVE_BLANK_LINE; blankLineSpacer = state.getLine(); } return BlockContinue.atIndex(state.getIndex()); } }
@Override public BlockStart tryStart(ParserState state, MatchedBlockParser matchedBlockParser) { BasedSequence line = state.getLine(); if (state.getIndex() == 0) { int breakLength = myOptions.exampleBreak.length(); if (line.length() >= breakLength + 1 + EXAMPLE_KEYWORD.length() && line.startsWith(myOptions.exampleBreak) && line.matchChars(EXAMPLE_KEYWORD, breakLength + 1) && " \t\u00A0".contains(String.valueOf(line.charAt(breakLength)))) { SpecExampleBlockParser blockParser = new SpecExampleBlockParser(state.getProperties()); blockParser.block.setOpeningMarker(line.subSequence(0, breakLength)); //blockParser.addLine(state, state.getLineWithEOL()); return BlockStart.of(blockParser).atIndex(-1); } } return BlockStart.none(); } }
@Override public BlockStart tryStart(ParserState state, MatchedBlockParser matchedBlockParser) { if (state.getIndent() >= 4) { return BlockStart.none(); } BasedSequence line = state.getLine(); int nextNonSpace = state.getNextNonSpaceIndex(); BasedSequence trySequence = line.subSequence(nextNonSpace, line.length()); Matcher matcher = myParsing.TOC_BLOCK_START.matcher(line); if (matcher.matches()) { BasedSequence tocChars = state.getLineWithEOL(); BasedSequence styleChars = null; BasedSequence titleChars = null; if (matcher.start(1) != -1) { int styleStart = matcher.start(1); int styleEnd = matcher.end(1); styleChars = trySequence.subSequence(styleStart, styleEnd); } TocBlockParser tocBlockParser = new TocBlockParser(state.getProperties(), tocChars, styleChars); return BlockStart.of(tocBlockParser) .atIndex(state.getIndex()) //.replaceActiveBlockParser() ; } return none(); } }
@Override public BlockContinue tryContinue(ParserState state) { if (deepParser != null) { if (state.isBlank()) { if (deepParser.isHtmlClosed() || myHtmlBlockDeepParseBlankLineInterrupts && !deepParser.haveOpenRawTag() || (myHtmlBlockDeepParseBlankLineInterruptsPartialTag && deepParser.isBlankLineInterruptible())) { return BlockContinue.none(); } } return BlockContinue.atIndex(state.getIndex()); } else { if (finished) { return BlockContinue.none(); } // Blank line ends type 6 and type 7 blocks if (state.isBlank() && closingPattern == null) { return BlockContinue.none(); } else { return BlockContinue.atIndex(state.getIndex()); } } }
@Override public BlockStart tryStart(ParserState state, MatchedBlockParser matchedBlockParser) { BasedSequence line = state.getLine(); int currentIndent = state.getIndent(); if (currentIndent == 0 && !(matchedBlockParser.getBlockParser().getBlock() instanceof Paragraph)) { final BasedSequence tryLine = line.subSequence(state.getIndex()); Matcher matcher = parsing.MACRO_OPEN.matcher(tryLine); if (matcher.find()) { // see if it closes on the same line, then we create a block and close it BasedSequence tag = tryLine.subSequence(0, matcher.end()); BasedSequence tagName = line.subSequence(matcher.start(1), matcher.end(1)); BasedSequence parameters = tryLine.subSequence(matcher.end(1), matcher.end() - 2).trim(); JekyllTag tagNode = new JekyllTag(tag.subSequence(0, 2), tagName, parameters, tag.endSequence(2)); tagNode.setCharsFromContent(); final JekyllTagBlockParser parser = new JekyllTagBlockParser(state.getProperties()); parser.block.appendChild(tagNode); //noinspection EqualsBetweenInconvertibleTypes if (!listIncludesOnly || tagName.equals(INCLUDE_TAG)) { List<JekyllTag> tagList = JekyllTagExtension.TAG_LIST.getFrom(state.getProperties()); tagList.add(tagNode); } return BlockStart.of(parser) .atIndex(state.getLineEndIndex()) ; } } return BlockStart.none(); } }
@Override public BlockContinue tryContinue(ParserState state) { int nextNonSpace = state.getNextNonSpaceIndex(); int newIndex = state.getIndex(); BasedSequence line = state.getLine(); Matcher matcher; boolean matches = (state.getIndent() <= 3 && nextNonSpace < line.length() && (!matchingCloser || line.charAt(nextNonSpace) == fenceChar)); if (matches) { BasedSequence trySequence = line.subSequence(nextNonSpace, line.length()); matcher = CLOSING_FENCE.matcher(trySequence); if (matcher.find()) { int foundFenceLength = matcher.group(0).length(); if (foundFenceLength >= fenceLength) { // closing fence - we're at end of line, so we can finalize now block.setClosingMarker(trySequence.subSequence(0, foundFenceLength)); return BlockContinue.finished(); } } } // skip optional spaces of fence indent int i = fenceIndent; while (i > 0 && newIndex < line.length() && line.charAt(newIndex) == ' ') { newIndex++; i--; } return BlockContinue.atIndex(newIndex); }
@Override public BlockContinue tryContinue(ParserState state) { if (hadClose) { return BlockContinue.none(); } final int index = state.getIndex(); BasedSequence line = state.getLineWithEOL(); final Matcher matcher = MACRO_BLOCK_END.matcher(line); if (!matcher.matches()) { return BlockContinue.atIndex(index); } else { // if have open gitlab block quote last child then let them handle it Node lastChild = block.getLastChild(); if (lastChild instanceof GitLabBlockQuote) { //final BlockParser parser = state.getActiveBlockParser((Block) lastChild); if (((GitLabBlockQuote) lastChild).getClosingMarker().isEmpty()) { // let the child handle it return BlockContinue.atIndex(index); } } hadClose = true; block.setClosingMarker(state.getLine().subSequence(index, index + 3)); block.setClosingTrailing(state.getLineWithEOL().subSequence(matcher.start(1), matcher.end(1))); return BlockContinue.atIndex(state.getLineEndIndex()); } }
@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) { if (hadClose) { return BlockContinue.none(); } final int index = state.getIndex(); BasedSequence line = state.getLineWithEOL(); final Matcher matcher = GIT_LAB_BLOCK_END.matcher(line.subSequence(index)); if (!matcher.matches()) { return BlockContinue.atIndex(index); } else { // if have open gitlab block quote last child then let them handle it Node lastChild = block.getLastChild(); if (lastChild instanceof GitLabBlockQuote) { final BlockParser parser = state.getActiveBlockParser((Block) lastChild); if (parser instanceof GitLabBlockQuoteParser && !((GitLabBlockQuoteParser) parser).hadClose) { // let the child handle it return BlockContinue.atIndex(index); } } hadClose = true; block.setClosingMarker(state.getLine().subSequence(index, index + 3)); block.setClosingTrailing(state.getLineWithEOL().subSequence(matcher.start(1), matcher.end(1))); return BlockContinue.atIndex(state.getLineEndIndex()); } }
@Override public BlockContinue tryContinue(ParserState state) { final int nonSpaceIndex = state.getNextNonSpaceIndex(); if (state.isBlank()) { if (block.getFirstChild() == null) { // Blank line after empty list item return BlockContinue.none(); } else { return BlockContinue.atIndex(nonSpaceIndex); } } if (state.getIndent() >= options.contentIndent) { int contentIndent = state.getIndex() + options.contentIndent; return BlockContinue.atIndex(contentIndent); } else { return BlockContinue.none(); } }
@Override public BlockContinue tryContinue(ParserState state) { final int nonSpaceIndex = state.getNextNonSpaceIndex(); if (state.isBlank()) { if (block.getFirstChild() == null) { // Blank line after empty list item return BlockContinue.none(); } else { return BlockContinue.atIndex(nonSpaceIndex); } } if (state.getIndent() >= options.contentIndent) { int contentIndent = state.getIndex() + options.contentIndent; return BlockContinue.atIndex(contentIndent); } else { return BlockContinue.none(); } }