// tok must come from htmlTok // returns all container tags found (including content) as CNC // might not be correct with HTML sources static L<L<S>> findContainerTags(L<S> tok) { new L<L<S>> 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; }
Began life as a copy of #1002309
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1007927 |
| Snippet name: | findContainerTags - HTML/XML parsing |
| Eternal ID of this version: | #1007927/4 |
| Text MD5: | 4e8a7eec69e26347f0a458be1ecf800b |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2021-07-24 03:12:59 |
| Source code size: | 636 bytes / 22 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 729 / 758 |
| Version history: | 3 change(s) |
| Referenced in: | [show references] |