org.commonmark.node.HtmlInline Java Examples
The following examples show how to use
org.commonmark.node.HtmlInline.
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 |
private void printAttributes(StringBuilder buf, Node node) { if (node instanceof Text) printAttribute(buf, "literal", ((Text)node).getLiteral()); else if (node instanceof Code) printAttribute(buf, "literal", ((Code)node).getLiteral()); else if (node instanceof IndentedCodeBlock) printAttribute(buf, "literal", ((IndentedCodeBlock)node).getLiteral()); else if (node instanceof FencedCodeBlock) printAttribute(buf, "literal", ((FencedCodeBlock)node).getLiteral()); else if (node instanceof HtmlBlock) printAttribute(buf, "literal", ((HtmlBlock)node).getLiteral()); else if (node instanceof HtmlInline) printAttribute(buf, "literal", ((HtmlInline)node).getLiteral()); else if (node instanceof Link) { printAttribute(buf, "destination", ((Link)node).getDestination()); printAttribute(buf, "title", ((Link)node).getTitle()); } else if (node instanceof Image) { printAttribute(buf, "destination", ((Image)node).getDestination()); printAttribute(buf, "title", ((Image)node).getTitle()); } else if (node instanceof Heading) printAttribute(buf, "level", ((Heading)node).getLevel()); }
Example #2
Source File: DocMaker.java From jeka with Apache License 2.0 | 6 votes |
private void addMenu(Node document, List<MenuItem> menuItems) { final List<MenuItem> reversedItems = new LinkedList<>(menuItems); Collections.reverse(reversedItems); for (final MenuItem menuItem : reversedItems) { if (menuItem.level > 5) { continue; } final Link link = new Link(); link.setTitle(menuItem.title); final Text text = new Text(); text.setLiteral( menuItem.title); link.appendChild(text); link.setDestination("#" + menuItem.anchorId); final HtmlInline indent = new HtmlInline(); final String cssClass = "menuItem" + menuItem.level; indent.setLiteral("<a href=\"#" + menuItem.anchorId + "\" class=\"" + cssClass + "\">" + menuItem.title + "</a>"); document.prependChild(indent); document.prependChild(new HardLineBreak()); } }
Example #3
Source File: HtmlInlineProcessor.java From Markwon with Apache License 2.0 | 5 votes |
@Override protected Node parse() { String m = match(HTML_TAG); if (m != null) { HtmlInline node = new HtmlInline(); node.setLiteral(m); return node; } else { return null; } }
Example #4
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; }
Example #5
Source File: MarkwonVisitorImpl.java From Markwon with Apache License 2.0 | 4 votes |
@Override public void visit(HtmlInline htmlInline) { visit((Node) htmlInline); }