org.commonmark.node.Block Java Examples
The following examples show how to use
org.commonmark.node.Block.
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: ListItemParser.java From commonmark-java with BSD 2-Clause "Simplified" License | 6 votes |
@Override public BlockContinue tryContinue(ParserState state) { if (state.isBlank()) { if (block.getFirstChild() == null) { // Blank line after empty list item return BlockContinue.none(); } else { Block activeBlock = state.getActiveBlockParser().getBlock(); // If the active block is a code block, blank lines in it should not affect if the list is tight. hadBlankLine = activeBlock instanceof Paragraph || activeBlock instanceof ListItem; return BlockContinue.atIndex(state.getNextNonSpaceIndex()); } } if (state.getIndent() >= contentIndent) { return BlockContinue.atColumn(state.getColumn() + contentIndent); } else { return BlockContinue.none(); } }
Example #2
Source File: MarkDownParser.java From blog-app-android with MIT License | 5 votes |
@Override public void visit(Paragraph paragraph) { super.visit(paragraph); final Block parent = paragraph.getParent(); if (parent instanceof Document) { if (parent.getFirstChild() == paragraph && parent.getLastChild() == paragraph) { while (paragraph.getFirstChild() != null) { paragraph.insertBefore(paragraph.getFirstChild()); } paragraph.unlink(); } } }
Example #3
Source File: ListItemParser.java From commonmark-java with BSD 2-Clause "Simplified" License | 5 votes |
@Override public boolean canContain(Block childBlock) { if (hadBlankLine) { // We saw a blank line in this list item, that means the list block is loose. // // spec: if any of its constituent list items directly contain two block-level elements with a blank line // between them Block parent = block.getParent(); if (parent instanceof ListBlock) { ((ListBlock) parent).setTight(false); } } return true; }
Example #4
Source File: MarkwonSpansFactoryImplTest.java From Markwon with Apache License 2.0 | 5 votes |
@Test public void builder() { // all passed to builder will be in factory final SpanFactory text = mock(SpanFactory.class); final SpanFactory link = mock(SpanFactory.class); final MarkwonSpansFactory factory = new MarkwonSpansFactoryImpl.BuilderImpl() .setFactory(Text.class, text) .setFactory(Link.class, link) .build(); assertNotNull(factory.get(Text.class)); assertNotNull(factory.get(Link.class)); // a bunch of non-present factories //noinspection unchecked final Class<? extends Node>[] types = new Class[]{ Image.class, Block.class, Emphasis.class, Paragraph.class }; for (Class<? extends Node> type : types) { assertNull(factory.get(type)); } }
Example #5
Source File: CorePlugin.java From Markwon with Apache License 2.0 | 5 votes |
/** * @return a set with enabled by default block types * @since 4.4.0 */ @NonNull public static Set<Class<? extends Block>> enabledBlockTypes() { return new HashSet<>(Arrays.asList( BlockQuote.class, Heading.class, FencedCodeBlock.class, HtmlBlock.class, ThematicBreak.class, ListBlock.class, IndentedCodeBlock.class )); }
Example #6
Source File: DumpNodes.java From Markwon with Apache License 2.0 | 5 votes |
@NonNull public static String dump(@NonNull Node node, @Nullable NodeProcessor nodeProcessor) { final NodeProcessor processor = nodeProcessor != null ? nodeProcessor : new NodeProcessorToString(); final Indent indent = new Indent(); final StringBuilder builder = new StringBuilder(); final Visitor visitor = (Visitor) Proxy.newProxyInstance( Visitor.class.getClassLoader(), new Class[]{Visitor.class}, new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) { final Node argument = (Node) args[0]; // initial indent indent.appendTo(builder); // node info builder.append(processor.process(argument)); if (argument instanceof Block) { builder.append(" [\n"); indent.increment(); visitChildren((Visitor) proxy, argument); indent.decrement(); indent.appendTo(builder); builder.append("]\n"); } else { builder.append('\n'); } return null; } }); node.accept(visitor); return builder.toString(); }
Example #7
Source File: FencedCodeBlockParser.java From commonmark-java with BSD 2-Clause "Simplified" License | 4 votes |
@Override public Block getBlock() { return block; }
Example #8
Source File: YamlFrontMatterBlockParser.java From commonmark-java with BSD 2-Clause "Simplified" License | 4 votes |
@Override public Block getBlock() { return block; }
Example #9
Source File: AbstractBlockParser.java From commonmark-java with BSD 2-Clause "Simplified" License | 4 votes |
@Override public boolean canContain(Block childBlock) { return false; }
Example #10
Source File: IndentedCodeBlockParser.java From commonmark-java with BSD 2-Clause "Simplified" License | 4 votes |
@Override public Block getBlock() { return block; }
Example #11
Source File: DocumentBlockParser.java From commonmark-java with BSD 2-Clause "Simplified" License | 4 votes |
@Override public boolean canContain(Block block) { return true; }
Example #12
Source File: HeadingParser.java From commonmark-java with BSD 2-Clause "Simplified" License | 4 votes |
@Override public Block getBlock() { return block; }
Example #13
Source File: NoticeBlockParser.java From maven-confluence-plugin with Apache License 2.0 | 4 votes |
@Override public boolean canContain(Block block) { return true; }
Example #14
Source File: ThematicBreakParser.java From commonmark-java with BSD 2-Clause "Simplified" License | 4 votes |
@Override public Block getBlock() { return block; }
Example #15
Source File: BlockQuoteParser.java From commonmark-java with BSD 2-Clause "Simplified" License | 4 votes |
@Override public boolean canContain(Block block) { return true; }
Example #16
Source File: ListItemParser.java From commonmark-java with BSD 2-Clause "Simplified" License | 4 votes |
@Override public Block getBlock() { return block; }
Example #17
Source File: HtmlBlockParser.java From commonmark-java with BSD 2-Clause "Simplified" License | 4 votes |
@Override public Block getBlock() { return block; }
Example #18
Source File: ParagraphParser.java From commonmark-java with BSD 2-Clause "Simplified" License | 4 votes |
@Override public Block getBlock() { return block; }
Example #19
Source File: TableBlockParser.java From commonmark-java with BSD 2-Clause "Simplified" License | 4 votes |
@Override public Block getBlock() { return block; }
Example #20
Source File: TableBlockParser.java From js-dossier with Apache License 2.0 | 4 votes |
@Override public Block getBlock() { return block; }
Example #21
Source File: AbstractBlockParser.java From 1Rramp-Android with MIT License | 4 votes |
@Override public boolean canContain(Block block) { return false; }
Example #22
Source File: JLatexMathBlockParser.java From Markwon with Apache License 2.0 | 4 votes |
@Override public Block getBlock() { return block; }
Example #23
Source File: JLatexMathBlockParserLegacy.java From Markwon with Apache License 2.0 | 4 votes |
@Override public Block getBlock() { return block; }
Example #24
Source File: TaskListBlockParser.java From Markwon with Apache License 2.0 | 4 votes |
@Override public Block getBlock() { return block; }
Example #25
Source File: ParagraphParser.java From 1Rramp-Android with MIT License | 4 votes |
@Override public Block getBlock() { return block; }
Example #26
Source File: HtmlBlockParser.java From 1Rramp-Android with MIT License | 4 votes |
@Override public Block getBlock() { return block; }
Example #27
Source File: ListItemParser.java From 1Rramp-Android with MIT License | 4 votes |
@Override public Block getBlock() { return block; }
Example #28
Source File: ListItemParser.java From 1Rramp-Android with MIT License | 4 votes |
@Override public boolean canContain(Block block) { return true; }
Example #29
Source File: BlockQuoteParser.java From 1Rramp-Android with MIT License | 4 votes |
@Override public boolean canContain(Block block) { return true; }
Example #30
Source File: ThematicBreakParser.java From 1Rramp-Android with MIT License | 4 votes |
@Override public Block getBlock() { return block; }