]. titlesource: --> charRangesOfHTMLComments [ranges include <!-- and -->] [1030488]

Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

21
LINES

< > BotCompany Repo | #1030488 // charRangesOfHTMLComments [ranges include <!-- and -->]

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2970L/17K).

static L<IntRange> charRangesOfHTMLComments(S html) {
  ret charRangesOfHTMLComments(htmlTok(html));
}

static L<IntRange> charRangesOfHTMLComments(LS tok) {
  new L<IntRange> l;
  int pos = 0;
  for idx over tok: {
    S t = tok.get(idx);
    if (even(idx)) {
      int i = 0;
      while ((i = indexOf(t, "<!--", i)) >= 0) {
        int j = smartIndexOf(t, "-->", i+4);
        l.add(intRange(pos+i, pos+j+3));
        i = j+3;
      }
    }
    pos += l(t);
  }
  ret l;
}

Author comment

Began life as a copy of #1028644

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030488
Snippet name: charRangesOfHTMLComments [ranges include <!-- and -->]
Eternal ID of this version: #1030488/1
Text MD5: 5cbfeb87fcea187e9e4a64a9eacd1133
Transpilation MD5: d95dfa0ee9dba996d34f8fb09bddf55f
Author: stefan
Category: javax / html parsing
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-12-28 00:02:26
Source code size: 495 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 193 / 260
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)