if (!parser.getCurrent().isType(SymbolType.Whitespace)) return Symbol.nothing; while (parser.getCurrent().isType(SymbolType.Text) && parser.getCurrent().getContent().startsWith("-")) { String option = parser.getCurrent().getContent(); parser.moveNext(1); if (!parser.getCurrent().isType(SymbolType.Whitespace)) return Symbol.nothing; parser.moveNext(1); if (!parser.getCurrent().isType(SymbolType.Text)) return Symbol.nothing; String value = parser.getCurrent().getContent(); parser.moveNext(1); if (!parser.getCurrent().isType(SymbolType.Whitespace)) return Symbol.nothing; parser.moveNext(1); options.put(option, value); if (parser.getCurrent().isType(Link.symbolType)) { Maybe<Symbol> link = Link.symbolType.getWikiRule().parse(parser.getCurrent(), parser); if (link.isNothing()) return Symbol.nothing; addOptions(link.getValue(), options); return makeImageLink(current, link.getValue(), imageProperty); else if (parser.getCurrent().isType(SymbolType.Text)) { Symbol list = new Symbol(SymbolType.SymbolList).add(parser.getCurrent()); Symbol link = new Symbol(Link.symbolType).add(list); addOptions(link, options);
if (!parser.getCurrent().isType(SymbolType.Whitespace)) return Symbol.nothing; while (parser.getCurrent().isType(SymbolType.Text) && parser.getCurrent().getContent().startsWith("-")) { String option = parser.getCurrent().getContent(); parser.moveNext(1); if (!parser.getCurrent().isType(SymbolType.Whitespace)) return Symbol.nothing; parser.moveNext(1); if (!parser.getCurrent().isType(SymbolType.Text)) return Symbol.nothing; String value = parser.getCurrent().getContent(); parser.moveNext(1); if (!parser.getCurrent().isType(SymbolType.Whitespace)) return Symbol.nothing; parser.moveNext(1); options.put(option, value); if (parser.getCurrent().isType(Link.symbolType)) { Maybe<Symbol> link = Link.symbolType.getWikiRule().parse(parser.getCurrent(), parser); if (link.isNothing()) return Symbol.nothing; addOptions(link.getValue(), options); return makeImageLink(current, link.getValue(), imageProperty); else if (parser.getCurrent().isType(SymbolType.Text)) { Symbol list = new Symbol(SymbolType.SymbolList).add(parser.getCurrent()); Symbol link = new Symbol(Link.symbolType).add(list); addOptions(link, options);
@Override public Maybe<Symbol> parse(Symbol current, Parser parser) { Symbol nesting = parser.parseTo(SymbolType.CloseNesting, ParseSpecification.nestingPriority); if (!parser.getCurrent().isType(SymbolType.CloseNesting)) return Symbol.nothing; current.add(nesting); return new Maybe<>(current); }
@Override public Maybe<Symbol> parse(Symbol current, Parser parser) { Symbol nesting = parser.parseTo(SymbolType.CloseNesting, ParseSpecification.nestingPriority); if (!parser.getCurrent().isType(SymbolType.CloseNesting)) return Symbol.nothing; current.add(nesting); return new Maybe<>(current); }
@Override public Maybe<Symbol> parse(Symbol current, Parser parser) { Symbol body = parser.parseToIgnoreFirst(current.getType()); if (body.getChildren().isEmpty()) return Symbol.nothing; if (!parser.getCurrent().isType(current.getType())) return Symbol.nothing; return new Maybe<>(current.add(body)); } }
@Override public Maybe<Symbol> parse(Symbol current, Parser parser) { Symbol body = parser.parseToIgnoreFirst(current.getType()); if (body.getChildren().isEmpty()) return Symbol.nothing; if (!parser.getCurrent().isType(current.getType())) return Symbol.nothing; return new Maybe<>(current.add(body)); } }
@Override public Maybe<Symbol> parse(Symbol current, Parser parser) { while (true) { Symbol row = new Symbol(SymbolType.SymbolList); current.add(row); for (int i = 0; i < 2; i++) { Symbol cell = parser.parseToIgnoreFirst(terminators); if (parser.atEnd() || cell.getChildren().isEmpty()) return Symbol.nothing; row.add(cell); } if (parser.getCurrent().isType(SymbolType.CloseBrace)) break; } return new Maybe<>(current); }
public Maybe<String> parseToAsString(SymbolType terminator) { int start = scanner.getOffset(); scanner.markStart(); parseTo(terminator); if (!atEnd() && !getCurrent().isType(terminator)) return Maybe.noString; return scanner.stringFromStart(start); }
@Override public Maybe<Symbol> parse(Symbol current, Parser parser) { if (current.getStartOffset() != 0) return Symbol.nothing; final Symbol frontMatter = parser.parseToWithSymbols(CloseFrontMatter.symbolType, SYMBOL_PROVIDER, 0); if (!parser.getCurrent().isType(CloseFrontMatter.symbolType)) return Symbol.nothing; Maybe<Symbol> yaml = processYaml(current, frontMatter); if (yaml.isNothing()) { return Symbol.nothing; } return new Maybe<>(current); }
@Override public Maybe<Symbol> parse(Symbol current, Parser parser) { while (true) { Symbol row = new Symbol(SymbolType.SymbolList); current.add(row); for (int i = 0; i < 2; i++) { Symbol cell = parser.parseToIgnoreFirst(terminators); if (parser.atEnd() || cell.getChildren().isEmpty()) return Symbol.nothing; row.add(cell); } if (parser.getCurrent().isType(SymbolType.CloseBrace)) break; } return new Maybe<>(current); }
public Maybe<String> parseToAsString(SymbolType terminator) { int start = scanner.getOffset(); scanner.markStart(); parseTo(terminator); if (!atEnd() && !getCurrent().isType(terminator)) return Maybe.noString; return scanner.stringFromStart(start); }
@Override public Maybe<Symbol> parse(Symbol current, Parser parser) { if (current.getStartOffset() != 0) return Symbol.nothing; final Symbol frontMatter = parser.parseToWithSymbols(CloseFrontMatter.symbolType, SYMBOL_PROVIDER, 0); if (!parser.getCurrent().isType(CloseFrontMatter.symbolType)) return Symbol.nothing; Maybe<Symbol> yaml = processYaml(current, frontMatter); if (yaml.isNothing()) { return Symbol.nothing; } return new Maybe<>(current); }
@Override public Maybe<Symbol> parse(Symbol current, Parser parser) { Symbol table = parser.getCurrent(); table.putProperty("class", "plain_text_table"); Symbol cellSeparator = parser.getCurrent(); if (!cellSeparator.isType(SymbolType.Newline) && !cellSeparator.isType(SymbolType.Whitespace)) { SymbolType plainTextCellSeparator = new SymbolType("PlainTextCellSeparator"); if (parser.getCurrent().isType(SymbolType.Whitespace)) { table.putProperty("hideFirst", ""); Symbol line = parser.parseToWithSymbols(terminators, plainTextTableTypes, 0); if (parser.atEnd()) return Symbol.nothing; if (parser.getCurrent().isType(SymbolType.ClosePlainTextTable)) return new Maybe<>(table); if (row == null) { row = new Symbol(SymbolType.SymbolList); if (parser.getCurrent().isType(SymbolType.Newline)) row = null;
@Override public Maybe<Symbol> parse(Symbol current, Parser parser) { Symbol table = parser.getCurrent(); table.putProperty("class", "plain_text_table"); Symbol cellSeparator = parser.getCurrent(); if (!cellSeparator.isType(SymbolType.Newline) && !cellSeparator.isType(SymbolType.Whitespace)) { SymbolType plainTextCellSeparator = new SymbolType("PlainTextCellSeparator"); if (parser.getCurrent().isType(SymbolType.Whitespace)) { table.putProperty("hideFirst", ""); Symbol line = parser.parseToWithSymbols(terminators, plainTextTableTypes, 0); if (parser.atEnd()) return Symbol.nothing; if (parser.getCurrent().isType(SymbolType.ClosePlainTextTable)) return new Maybe<>(table); if (row == null) { row = new Symbol(SymbolType.SymbolList); if (parser.getCurrent().isType(SymbolType.Newline)) row = null;
@Override public Maybe<Symbol> parse(Symbol current, Parser parser) { String content = current.getContent(); if (content.charAt(0) == '-') current.putProperty("hideFirst", ""); boolean endOfTable = false; while (!endOfTable) { Symbol row = new Symbol(tableRow); row.setStartOffset(parser.getOffset()); current.add(row); while (true) { int offset = parser.getOffset(); Symbol cell = parseCell(parser, content); if (parser.getOffset() == offset) { endOfTable = true; break; } if (parser.atEnd()) return Symbol.nothing; if (containsNewLine(cell)) return Symbol.nothing; row.add(cell); if (endsRow(parser.getCurrent())) break; } row.setEndOffset(parser.getOffset()); if (!startsRow(parser.getCurrent())) break; } return new Maybe<>(current); }
@Override public Maybe<Symbol> parse(Symbol current, Parser parser) { String content = current.getContent(); if (content.charAt(0) == '-') current.putProperty("hideFirst", ""); boolean endOfTable = false; while (!endOfTable) { Symbol row = new Symbol(tableRow); row.setStartOffset(parser.getOffset()); current.add(row); while (true) { int offset = parser.getOffset(); Symbol cell = parseCell(parser, content); if (parser.getOffset() == offset) { endOfTable = true; break; } if (parser.atEnd()) return Symbol.nothing; if (containsNewLine(cell)) return Symbol.nothing; row.add(cell); if (endsRow(parser.getCurrent())) break; } row.setEndOffset(parser.getOffset()); if (!startsRow(parser.getCurrent())) break; } return new Maybe<>(current); }