@Override public String toMarkup(boolean prettyPrint) { return toMarkup(this, prettyPrint); }
@Override public String toString() { return Tables.toMarkup(tables, false, new AnnotationMarkupPrinter()); }
public static String toMarkup(Example example, boolean prettyPrint) { return toMarkup(example, prettyPrint, new MarkupPrinter.Default()); }
public static String toMarkup(Example example, boolean prettyPrint, MarkupPrinter printer) { StringBuilder sb = new StringBuilder(); if (example.hasChild()) { sb.append(Rows.toMarkup(example.firstChild(), prettyPrint, printer)); } else { sb.append(EMPTY); } if (example.hasSibling()) { sb.append("\n****\n"); sb.append(toMarkup(example.nextSibling(), prettyPrint, printer)); } return sb.toString(); }
@Test public void testEmptyTable_ShouldBeVisibleAsEmpty() { Tables emptyTable = new Tables(); String markup = "(empty table)"; assertEquals(markup, emptyTable.toMarkup()); }
public Tables structure() { HtmlDocumentBuilder parser = HtmlDocumentBuilder.tablesAndLists(); Example example = parser.parse(html); return Tables.parse(Tables.toMarkup(example, false)); } }
@Test public void testEmptyRowInATable_ShouldBeVisibleAsEmpty() { Tables emptyRowInATable = new Tables(); emptyRowInATable.row(1, 2, 3).row().row(7, 8, 9); String markup = "[ 1 ][ 2 ][ 3 ]\n(empty row)\n[ 7 ][ 8 ][ 9 ]"; assertEquals(markup, emptyRowInATable.toMarkup()); }
@Test public void testSeveralTables_ShouldBeSeparatedWithARowOfStarsWhenDisplayed() { Tables tables = new Tables(); tables.row(1, 2).row(3, 4); tables.table().row(5, 6).row(7, 8); String markup = "[ 1 ][ 2 ]\n[ 3 ][ 4 ]\n****\n[ 5 ][ 6 ]\n[ 7 ][ 8 ]"; assertEquals(markup, tables.toMarkup()); }