@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) { 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) { 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 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 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 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(); } }
content.add(state.getLineWithEOL().subSequence(newOffset), state.getIndent());
@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(); } }
content.add(state.getLineWithEOL().subSequence(newOffset), state.getIndent());