Transpiled version (84L) is out of date.
1 | // TODO: process CDATA, scripts |
2 | |
3 | static LS htmlcoarsetok(S s) { |
4 | new LS tok; |
5 | int l = s == null ? 0 : s.length(); |
6 | |
7 | int i = 0; |
8 | while (i < l) { |
9 | int j = i; |
10 | char c; |
11 | |
12 | // scan for non-tags |
13 | while (j < l) { |
14 | if (s.charAt(j) != '<') |
15 | // regular character |
16 | ++j; |
17 | else if (s.substring(j, Math.min(j+4, l)).equals("<!--")) { |
18 | // HTML comment |
19 | j = j+3; |
20 | do ++j; while (j < l && !s.substring(j, Math.min(j+3, l)).equals("-->")); |
21 | j = Math.min(j+3, l); |
22 | } else { |
23 | char d = charAt(s, j+1); // character after < |
24 | if (d == '/' || isLetter(d)) |
25 | // it's a tag |
26 | break; |
27 | else |
28 | ++j; |
29 | } |
30 | } |
31 | |
32 | tok.add(s.substring(i, j)); // add non-tag content |
33 | i = j; |
34 | if (i >= l) break; |
35 | c = s.charAt(i); |
36 | |
37 | // scan over tag |
38 | if (c == '<') { |
39 | ++j; |
40 | |
41 | while (j < l && s.charAt(j) != '>') ++j; // TODO: strings in tag? |
42 | if (j < l) ++j; |
43 | } |
44 | |
45 | tok.add(s.substring(i, j)); // add tag |
46 | i = j; |
47 | } |
48 | |
49 | if ((tok.size() & 1) == 0) tok.add(""); |
50 | return tok; |
51 | } |
download show line numbers debug dex old transpilations
Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1000670 |
Snippet name: | htmlcoarsetok (function) |
Eternal ID of this version: | #1000670/6 |
Text MD5: | f782f73d604810e4c861182426c30c61 |
Author: | stefan |
Category: | |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-09-24 20:29:17 |
Source code size: | 1151 bytes / 51 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 796 / 2061 |
Version history: | 5 change(s) |
Referenced in: | [show references] |