@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 BlockStart tryStart(ParserState state, MatchedBlockParser matchedBlockParser) { if (options.nestedBlockQuotes || !haveBlockQuoteParser(state)) { BasedSequence line = state.getLineWithEOL(); final Matcher matcher = GIT_LAB_BLOCK_START.matcher(line); if (matcher.matches()) { return BlockStart.of(new GitLabBlockQuoteParser(state.getProperties(), line.subSequence(0, 3), line.subSequence(matcher.start(1), matcher.end(1)))) .atIndex(state.getLineEndIndex()) //.replaceActiveBlockParser() ; } } return BlockStart.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) { 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 BlockStart tryStart(ParserState state, MatchedBlockParser matchedBlockParser) { CharSequence line = state.getLine(); BlockParser parentParser = matchedBlockParser.getBlockParser(); // check whether this line is the first line of whole document or not if (parentParser instanceof DocumentBlockParser && parentParser.getBlock().getFirstChild() == null && REGEX_BEGIN.matcher(line).matches()) { return BlockStart.of(new YamlFrontMatterBlockParser()).atIndex(state.getNextNonSpaceIndex()); } return BlockStart.none(); } }
@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 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) { BasedSequence line = state.getLine(); BlockParser parentParser = matchedBlockParser.getBlockParser(); if (parentParser instanceof DocumentBlockParser && parentParser.getBlock().getFirstChild() == null) { Matcher matcher = JEKYLL_FRONT_MATTER_BLOCK_START.matcher(line); if (matcher.matches()) { BasedSequence openingMarker = line.subSequence(0, 3); JekyllFrontMatterBlockParser parser = new JekyllFrontMatterBlockParser(state.getProperties(), openingMarker); return BlockStart.of(parser).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) { styleChars = trySequence.subSequence(matcher.start(1), matcher.end(1)); } if (matcher.start(2) != -1) { titleChars = trySequence.subSequence(matcher.start(2), matcher.end(2)); } SimTocBlockParser simTocBlockParser = new SimTocBlockParser(state.getProperties(), tocChars, styleChars, titleChars); return BlockStart.of(simTocBlockParser) .atIndex(state.getLineEndIndex() + state.getLineEolLength()) //.replaceActiveBlockParser() ; } return 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 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 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(); } } }
admonitionBlockParser.block.setTitleChars(titleChars); return BlockStart.of(admonitionBlockParser) .atIndex(line.length()); } else {
@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 = FOOTNOTE_DEF_PATTERN.matcher(trySequence); if (matcher.find()) { // abbreviation definition int openingStart = nextNonSpace + matcher.start(); int openingEnd = nextNonSpace + matcher.end(); BasedSequence openingMarker = line.subSequence(openingStart, openingStart + 2); BasedSequence text = line.subSequence(openingStart + 2, openingEnd - 2).trim(); BasedSequence closingMarker = line.subSequence(openingEnd - 2, openingEnd); int contentOffset = options.contentIndent; FootnoteBlockParser footnoteBlockParser = new FootnoteBlockParser(options, contentOffset); footnoteBlockParser.block.setOpeningMarker(openingMarker); footnoteBlockParser.block.setText(text); footnoteBlockParser.block.setClosingMarker(closingMarker); return BlockStart.of(footnoteBlockParser) .atIndex(openingEnd); } else { 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 = ENUM_REF_DEF_PATTERN.matcher(trySequence); if (matcher.find()) { // abbreviation definition int openingStart = nextNonSpace + matcher.start(); int openingEnd = nextNonSpace + matcher.end(); BasedSequence openingMarker = line.subSequence(openingStart, openingStart + 2); BasedSequence text = line.subSequence(openingStart + 2, openingEnd - 2).trim(); BasedSequence closingMarker = line.subSequence(openingEnd - 2, openingEnd); int contentOffset = options.contentIndent; EnumeratedReferenceBlockParser enumeratedReferenceBlockParser = new EnumeratedReferenceBlockParser(options, contentOffset); enumeratedReferenceBlockParser.block.setOpeningMarker(openingMarker); enumeratedReferenceBlockParser.block.setText(text); enumeratedReferenceBlockParser.block.setClosingMarker(closingMarker); return BlockStart.of(enumeratedReferenceBlockParser) .atIndex(openingEnd); } else { 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 = ABBREVIATION_BLOCK.matcher(trySequence); if (matcher.find()) { // abbreviation definition int openingStart = nextNonSpace + matcher.start(); int openingEnd = nextNonSpace + matcher.end(); BasedSequence openingMarker = trySequence.subSequence(openingStart, openingStart + 2); BasedSequence text = trySequence.subSequence(openingStart + 2, openingEnd - 2).trim(); BasedSequence closingMarker = trySequence.subSequence(openingEnd - 2, openingEnd); AbbreviationBlockParser abbreviationBlock = new AbbreviationBlockParser(); abbreviationBlock.block.setOpeningMarker(openingMarker); abbreviationBlock.block.setText(text); abbreviationBlock.block.setClosingMarker(closingMarker); abbreviationBlock.block.setAbbreviation(trySequence.subSequence(matcher.end()).trim()); abbreviationBlock.block.setCharsFromContent(); return BlockStart.of(abbreviationBlock) .atIndex(line.length()); } else { return BlockStart.none(); } } }
@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(); } } }
public BlockStart tryStart(ParserState state, MatchedBlockParser matchedBlockParser) { int nextNonSpace = state.getNextNonSpaceIndex(); if (isMarker(state, nextNonSpace) && !endsWithMarker(state.getLine())) { int newColumn = state.getColumn() + state.getIndent() + 1; // optional following space or tab if (Parsing.isSpaceOrTab(state.getLine(), nextNonSpace + 1)) { newColumn++; } return BlockStart.of(new AsideBlockParser(state.getProperties(), state.getLine().subSequence(nextNonSpace, nextNonSpace + 1))).atColumn(newColumn); } else { return BlockStart.none(); } } }
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(); } } }
ItemData itemData = parseItemMarker(options, state, state.getActiveBlockParser() instanceof ParagraphParser); if (itemData != null) { final BlockStart blockStart = BlockStart.of(new DefinitionItemBlockParser(state.getProperties(), itemData)) .atColumn(itemData.markerColumn + itemData.contentOffset); return blockStart;