public void visit(HtmlBlockNode node) { String text = node.getText(); if (text.length() > 0) printer.println(); printer.print(text); }
@Override public void visit(TableCaptionNode node) { printer.println().print("<caption>"); visitChildren(node); printer.print("</caption>"); }
public void visit(TableCellNode node) { String tag = inTableHeader ? "th" : "td"; List<TableColumnNode> columns = currentTableNode.getColumns(); TableColumnNode column = columns.get(Math.min(currentTableColumn, columns.size() - 1)); printer.println().print('<').print(tag); column.accept(this); if (node.getColSpan() > 1) printer.print(" colspan=\"").print(Integer.toString(node.getColSpan())).print('"'); printer.print('>'); visitChildren(node); printer.print('<').print('/').print(tag).print('>'); currentTableColumn += node.getColSpan(); }
protected void printConditionallyIndentedTag(SuperNode node, String tag) { if (node.getChildren().size() > 1) { printer.println().print('<').print(tag).print('>').indent(+2); visitChildren(node); printer.indent(-2).println().print('<').print('/').print(tag).print('>'); } else { boolean startWasNewLine = printer.endsWithNewLine(); printer.println().print('<').print(tag).print('>'); visitChildren(node); printer.print('<').print('/').print(tag).print('>').printchkln(startWasNewLine); } }
@Override public void serialize(final VerbatimNode node, final Printer printer) { printer.println().print("<pre><code"); if (!StringUtils.isEmpty(node.getType())) { printAttribute(printer, "class", node.getType()); } printer.print(">"); String text = node.getText(); // print HTML breaks for all initial newlines while (text.charAt(0) == '\n') { printer.print("<br/>"); text = text.substring(1); } printer.printEncoded(text); printer.print("</code></pre>"); }
public void visit(SimpleNode node) { switch (node.getType()) { case Apostrophe: printer.print("’"); break; case Ellipsis: printer.print("…"); break; case Emdash: printer.print("—"); break; case Endash: printer.print("–"); break; case HRule: printer.println().print("<hr/>"); break; case Linebreak: printer.print("<br/>"); break; case Nbsp: printer.print(" "); break; default: throw new IllegalStateException(); } }
public void visit(ListItemNode node) { if (node instanceof TaskListNode) { // vsch: #185 handle GitHub style task list items, these are a bit messy because the <input> checkbox needs to be // included inside the optional <p></p> first grand-child of the list item, first child is always RootNode // because the list item text is recursively parsed. Node firstChild = node.getChildren().get(0).getChildren().get(0); boolean firstIsPara = firstChild instanceof ParaNode; int indent = node.getChildren().size() > 1 ? 2 : 0; boolean startWasNewLine = printer.endsWithNewLine(); printer.println().print("<li class=\"task-list-item\">").indent(indent); if (firstIsPara) { printer.println().print("<p>"); printer.print("<input type=\"checkbox\" class=\"task-list-item-checkbox\"" + (((TaskListNode) node).isDone() ? " checked=\"checked\"" : "") + " disabled=\"disabled\"></input>"); visitChildren((SuperNode) firstChild); // render the other children, the p tag is taken care of here visitChildrenSkipFirst(node); printer.print("</p>"); } else { printer.print("<input type=\"checkbox\" class=\"task-list-item-checkbox\"" + (((TaskListNode) node).isDone() ? " checked=\"checked\"" : "") + " disabled=\"disabled\"></input>"); visitChildren(node); } printer.indent(-indent).printchkln(indent != 0).print("</li>") .printchkln(startWasNewLine); } else { printConditionallyIndentedTag(node, "li"); } }
public void visit(ListItemNode node) { printer.println(); repeat(listMarker, listLevel); printer.print(" "); visitChildren(node); }
@Override public void visit(TableCaptionNode node) { printer.println().print("<caption>"); visitChildren(node); printer.print("</caption>"); }