// tok must come from htmlTok
// returns all container tags found (including content) as CNC
// might not be correct with HTML sources
static L> findContainerTags(L tok) {
new L> l;
for (int i = 1; i < l(tok); i += 2)
if (isOpeningTag(tok.get(i))) {
int j, level = 1;
for (j = i+2; j < tok.size(); j += 2)
if (isOpeningTag(tok.get(j)))
++level;
else if (isClosingTag(tok.get(j))) {
--level;
if (level == 0) {
l.add(subList(tok, i-1, j+2)); // actual CNC
break;
}
}
i = j;
}
ret l;
}