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(); }
public Rule TableCell() { return Sequence( NodeSequence( push(new TableCellNode()), TestNot(Sp(), Optional(':'), Sp(), OneOrMore('-'), Sp(), Optional(':'), Sp(), FirstOf('|', Newline())), Optional(Sp(), TestNot('|'), NotNewline()), OneOrMore( TestNot('|'), TestNot(Sp(), Newline()), Inline(), addAsChild(), Optional(Sp(), Test('|'), Test(Newline())) ) ), ZeroOrMore('|'), ((TableCellNode) peek()).setColSpan(Math.max(1, matchLength())) ); }
@Override public void visit(TableCellNode node) { if (inTableHeader) { for (Node child : node.getChildren()) { String title; if (child instanceof ExpLinkNode) { ExpLinkNode linkNode = (ExpLinkNode) child; title = linkNode.title; if (title == null) { throw new IllegalStateException(String.format("No title found for link node with url '%s'", linkNode.url)); } pendingCommand = statementParser.parse(title, ""); } else if (child instanceof RefLinkNode) { LinkNode linkNode = toLinkNode((RefLinkNode) child); title = linkNode.getTitle(); if (title == null) { throw new IllegalStateException(String.format("No title found for link node with reference '%s'. This can be caused by the associated link text being empty.", linkNode.getText())); } pendingCommand = statementParser.parse(title, ""); } } } // Call the super visit(TableCellNode) method and override visit(TableColumnNode) below, so that the concordion commands are added to the <th> tag escapeHtmlNodes = true; super.visit(node); escapeHtmlNodes = false; }
@Override public void visit(TableCellNode node) { if (inTableHeader) { for (Node child : node.getChildren()) { String title; if (child instanceof ExpLinkNode) { ExpLinkNode linkNode = (ExpLinkNode) child; title = linkNode.title; if (title == null) { throw new IllegalStateException(String.format("No title found for link node with url '%s'", linkNode.url)); } pendingCommand = statementParser.parse(title, ""); } else if (child instanceof RefLinkNode) { LinkNode linkNode = toLinkNode((RefLinkNode) child); title = linkNode.getTitle(); if (title == null) { throw new IllegalStateException(String.format("No title found for link node with reference '%s'. This can be caused by the associated link text being empty.", linkNode.getText())); } pendingCommand = statementParser.parse(title, ""); } } } // Call the super visit(TableCellNode) method and override visit(TableColumnNode) below, so that the concordion commands are added to the <th> tag escapeHtmlNodes = true; super.visit(node); escapeHtmlNodes = false; }
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)); String pstr = printer.getString(); if (pstr.length() > 0) { if (pstr.endsWith("\n") || pstr.endsWith(" ")) { printer.print("|"); } else { printer.print(" |"); } } else { printer.print("|"); } column.accept(this); if (node.getColSpan() > 1) printer.print(" colspan=\"").print(Integer.toString(node.getColSpan())).print('"'); visitChildren(node); currentTableColumn += node.getColSpan(); }
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)); String pstr = printer.getString(); if (pstr.length() > 0) { if (pstr.endsWith("\n") || pstr.endsWith(" ")) { printer.print("|"); } else { printer.print(" |"); } } else { printer.print("|"); } column.accept(this); if (node.getColSpan() > 1) printer.print(" colspan=\"").print(Integer.toString(node.getColSpan())).print('"'); visitChildren(node); currentTableColumn += node.getColSpan(); }
@SuppressWarnings("unchecked") @Override public void process(int level, Node node, InvocationContext context) { TreeNavigation nav = context.treeNavigation(); boolean isHeaderCell = nav.ancestorTreeMatches(TableCellNode.class, TableRowNode.class, TableHeaderNode.class); CellStyler cellStyler = context.peekCellStyler(); context.pushFont(cellStyler.cellFont()); List<Element> elements = context.collectChildren(level, node); context.popFont(); Phrase phrase = new Phrase(); phrase.addAll(elements); int colspan = ((TableCellNode) node).getColSpan(); PdfPCell cell = isHeaderCell ? headerCell(phrase) : new PdfPCell(phrase); cell.setColspan(colspan); cellStyler.applyStyle(cell); context.append(cell); }