org.commonmark.node.AbstractVisitor Java Examples
The following examples show how to use
org.commonmark.node.AbstractVisitor.
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: CommonmarkPreviewRenderer.java From markdown-writer-fx with BSD 2-Clause "Simplified" License | 6 votes |
@Override public List<Range> findSequences(int startOffset, int endOffset) { ArrayList<Range> sequences = new ArrayList<>(); Node astRoot = toAstRoot(); if (astRoot == null) return sequences; Visitor visitor = new AbstractVisitor() { @Override protected void visitChildren(Node node) { Range range = toSourcePositions().get(node); if (range != null && isInRange(startOffset, endOffset, range)) sequences.add(range); super.visitChildren(node); } }; astRoot.accept(visitor); return sequences; }
Example #2
Source File: MarkdownAssert.java From doov with Apache License 2.0 | 5 votes |
public IntegerAssert countOrderedList() { final AtomicInteger count = new AtomicInteger(); actual.accept(new AbstractVisitor() { @Override public void visit(OrderedList orderedList) { count.incrementAndGet(); super.visit(orderedList); } }); return new IntegerAssert(count.get()); }
Example #3
Source File: MarkdownAssert.java From doov with Apache License 2.0 | 5 votes |
public IntegerAssert countText() { final AtomicInteger count = new AtomicInteger(); actual.accept(new AbstractVisitor() { @Override public void visit(Text text) { count.incrementAndGet(); super.visit(text); } }); return new IntegerAssert(count.get()); }
Example #4
Source File: MarkdownAssert.java From doov with Apache License 2.0 | 5 votes |
public IntegerAssert countBulletList() { final AtomicInteger count = new AtomicInteger(); actual.accept(new AbstractVisitor() { @Override public void visit(BulletList bulletList) { count.incrementAndGet(); super.visit(bulletList); } }); return new IntegerAssert(count.get()); }
Example #5
Source File: MarkdownAssert.java From doov with Apache License 2.0 | 5 votes |
public IntegerAssert countListItem() { final AtomicInteger count = new AtomicInteger(); actual.accept(new AbstractVisitor() { @Override public void visit(ListItem listItem) { count.incrementAndGet(); super.visit(listItem); } }); return new IntegerAssert(count.get()); }
Example #6
Source File: MarkdownAssert.java From doov with Apache License 2.0 | 5 votes |
public ListAssert<String> textNodes() { final List<String> collector = new ArrayList<String>(); actual.accept(new AbstractVisitor() { @Override public void visit(Text text) { collector.add(text.getLiteral()); super.visit(text); } }); return new ListAssert<>(collector); }
Example #7
Source File: DocMaker.java From jeka with Apache License 2.0 | 5 votes |
private List<MenuItem> addAnchorAndNumberingToHeaders(Node node) { final List<MenuItem> menuItems = new LinkedList<>(); final int[] counters = new int[10]; node.accept(new AbstractVisitor() { @Override public void visit(Heading heading) { final Text text = (Text) heading.getFirstChild(); final String content = text.getLiteral(); final boolean intro = "Introduction".equals(content); // Do not number Introduction if (!intro) { counters[heading.getLevel()]++; for (int i = heading.getLevel() + 1; i < 6; i++) { counters[i] = 0; } } final StringBuilder sb = new StringBuilder(); for (int i = 1; i <= heading.getLevel(); i++) { sb.append(counters[i]).append("."); } if (sb.length() > 1 && heading.getLevel() > 1) { sb.delete(sb.length() - 1, sb.length() ); } final String anchorId = content.replace(" ", ""); final HtmlInline htmlInline = new HtmlInline(); htmlInline.setLiteral("<a name=\"" + anchorId + "\"></a>"); heading.insertBefore(htmlInline); final MenuItem menuItem = new MenuItem(content, anchorId, heading.getLevel()); menuItems.add(menuItem); } }); return menuItems; }