public void testSkipsInformativeSections() { Example tables = parse( "[First table]\n" + "****\n" + "[Begin Info]\n" + "****\n" + "[Should be skipped]\n" + "****\n" + "[End Info]\n" + "****\n" + "[Next table]\n" + "****\n" + "[Begin Info]\n" + "****\n" + "[Should be skipped too]\n" + "****\n" + "[End Info]\n" + "****\n" + "[Begin Info]\n" + "****\n" + "[Should be skipped]\n" + "****\n" + "[End Info]\n" + "****\n" + "[Last table]"); assertEquals("First table", tables.at(0, 0, 0).getContent()); tables = filter.filter(tables.nextSibling()); assertEquals("Next table", tables.at(0, 0, 0).getContent()); tables = filter.filter(tables.nextSibling()); tables = filter.filter(tables); assertEquals("Last table", tables.at(0, 0, 0).getContent()); }
public String interpretedElements() { CommentTableFilter ctf = new CommentTableFilter(); Example tableToFilter = Tables.parse(documentContent); StringBuilder ret = new StringBuilder(); boolean none = true; while (tableToFilter != null) { if (!ctf.canFilter(tableToFilter)) { ret.append(tableToFilter.firstChild().toString()); tableToFilter = tableToFilter.nextSibling(); none = false; } else { tableToFilter = ctf.filter(tableToFilter); } } if (none) { return "none"; } return ret.toString(); }