org.commonmark.parser.InlineParser Java Examples
The following examples show how to use
org.commonmark.parser.InlineParser.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TaskListBlockParser.java From Markwon with Apache License 2.0 | 6 votes |
@Override public void parseInlines(InlineParser inlineParser) { Matcher matcher; TaskListItem listItem; for (Item item : items) { matcher = PATTERN.matcher(item.line); if (!matcher.matches()) { continue; } listItem = new TaskListItem() .done(isDone(matcher.group(2))) .indent(item.indent / 2); inlineParser.parse(matcher.group(3), listItem); block.appendChild(listItem); } }
Example #2
Source File: MarkwonInlineParser.java From Markwon with Apache License 2.0 | 6 votes |
@Override public InlineParser create(InlineParserContext inlineParserContext) { final List<DelimiterProcessor> delimiterProcessors; final List<DelimiterProcessor> customDelimiterProcessors = inlineParserContext.getCustomDelimiterProcessors(); final int size = customDelimiterProcessors != null ? customDelimiterProcessors.size() : 0; if (size > 0) { delimiterProcessors = new ArrayList<>(size + this.delimiterProcessors.size()); delimiterProcessors.addAll(this.delimiterProcessors); delimiterProcessors.addAll(customDelimiterProcessors); } else { delimiterProcessors = this.delimiterProcessors; } return new MarkwonInlineParser( inlineParserContext, referencesEnabled, inlineProcessors, delimiterProcessors); }
Example #3
Source File: TableBlockParser.java From js-dossier with Apache License 2.0 | 6 votes |
@Override public void parseInlines(InlineParser inlineParser) { Node headNode = new TableHeadNode(); block.appendChild(headNode); headNode.appendChild(parseRow(headerRow.toString(), inlineParser)); // The first row of data is always the column alignments, which we've already parsed. Node bodyNode = new TableBodyNode(); block.appendChild(bodyNode); String caption = null; for (CharSequence line : Iterables.skip(rowData, 1)) { Matcher captionMatcher = CAPTION_LINE.matcher(line); if (captionMatcher.matches()) { caption = captionMatcher.group("content").trim(); } else { TableRowNode row = parseRow(line.toString(), inlineParser); bodyNode.appendChild(row); } } if (!isNullOrEmpty(caption)) { TableCaptionNode captionNode = new TableCaptionNode(); headNode.insertBefore(captionNode); inlineParser.parse(caption.trim(), captionNode); } }
Example #4
Source File: DocumentParser.java From 1Rramp-Android with MIT License | 5 votes |
public DocumentParser(List<BlockParserFactory> blockParserFactories, InlineParser inlineParser) { this.blockParserFactories = blockParserFactories; this.inlineParser = inlineParser; this.documentBlockParser = new DocumentBlockParser(); activateBlockParser(this.documentBlockParser); }
Example #5
Source File: DocumentParser.java From commonmark-java with BSD 2-Clause "Simplified" License | 5 votes |
/** * Walk through a block & children recursively, parsing string content into inline content where appropriate. */ private void processInlines() { InlineParserContextImpl context = new InlineParserContextImpl(delimiterProcessors, definitions); InlineParser inlineParser = inlineParserFactory.create(context); for (BlockParser blockParser : allBlockParsers) { blockParser.parseInlines(inlineParser); } }
Example #6
Source File: ParagraphParser.java From commonmark-java with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void parseInlines(InlineParser inlineParser) { CharSequence content = linkReferenceDefinitionParser.getParagraphContent(); if (content.length() > 0) { inlineParser.parse(content.toString(), block); } }
Example #7
Source File: TableBlockParser.java From commonmark-java with BSD 2-Clause "Simplified" License | 5 votes |
private TableCell parseCell(String cell, int column, InlineParser inlineParser) { TableCell tableCell = new TableCell(); if (column < columns.size()) { tableCell.setAlignment(columns.get(column)); } inlineParser.parse(cell.trim(), tableCell); return tableCell; }
Example #8
Source File: AbstractBlockParser.java From 1Rramp-Android with MIT License | 4 votes |
@Override public void parseInlines(InlineParser inlineParser) { }
Example #9
Source File: HeadingParser.java From 1Rramp-Android with MIT License | 4 votes |
@Override public void parseInlines(InlineParser inlineParser) { inlineParser.parse(content, block); }
Example #10
Source File: ParagraphParser.java From 1Rramp-Android with MIT License | 4 votes |
@Override public void parseInlines(InlineParser inlineParser) { if (content != null) { inlineParser.parse(content.getString(), block); } }
Example #11
Source File: YamlFrontMatterBlockParser.java From commonmark-java with BSD 2-Clause "Simplified" License | 4 votes |
@Override public void parseInlines(InlineParser inlineParser) { }
Example #12
Source File: AbstractBlockParser.java From commonmark-java with BSD 2-Clause "Simplified" License | 4 votes |
@Override public void parseInlines(InlineParser inlineParser) { }
Example #13
Source File: HeadingParser.java From commonmark-java with BSD 2-Clause "Simplified" License | 4 votes |
@Override public void parseInlines(InlineParser inlineParser) { inlineParser.parse(content, block); }
Example #14
Source File: TableBlockParser.java From js-dossier with Apache License 2.0 | 4 votes |
private TableRowNode parseRow(String rowStr, InlineParser inlineParser) { rowStr = rowStr.trim(); if (rowStr.startsWith("|")) { rowStr = rowStr.substring(1); } TableRowNode row = new TableRowNode(); boolean isEscaped = false; int currentColumn = 0; CharBuffer data = CharBuffer.wrap(rowStr); for (int index = 0; data.hasRemaining(); index++) { if (isEscaped) { isEscaped = false; continue; } char c = data.charAt(index); if (c == '\\') { isEscaped = true; continue; } if (c == '|' || (index + 1) >= data.remaining()) { int end = c == '|' ? index : index + 1; String content = data.subSequence(0, end).toString(); data.position(data.position() + end); int colSpan = 0; while (data.hasRemaining() && data.charAt(0) == '|') { colSpan++; data.position(data.position() + 1); } index = -1; // Account for post-forloop increment. Alignment alignment = currentColumn < columns.size() ? columns.get(currentColumn) : Alignment.NONE; currentColumn += colSpan; TableCellNode cell = new TableCellNode(colSpan, alignment); inlineParser.parse(content.trim(), cell); row.appendChild(cell); } } return row; }
Example #15
Source File: BlockParser.java From 1Rramp-Android with MIT License | votes |
void parseInlines(InlineParser inlineParser);
Example #16
Source File: BlockParser.java From commonmark-java with BSD 2-Clause "Simplified" License | votes |
void parseInlines(InlineParser inlineParser);