// tok should be the output of htmlcoarsetok static L dropAllTags(L tok) { new L list; for (int i = 0; i < tok.size(); i++) { S t = tok.get(i); if (t.startsWith("<")) { list.set(list.size()-1, list.get(list.size()-1) + tok.get(i+1)); ++i; } else list.add(tok.get(i)); } return list; } // alternatively, call this convenient function static S dropAllTags(S html) { return join(dropAllTags(htmlcoarsetok(html))); }