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

28
LINES

< > BotCompany Repo | #1029889 // findClosingTag

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

Transpiled version (2530L) is out of date.

1  
// tok must come from htmlTok
2  
// returns index of closing tag or l(tok)
3  
static int findClosingTag(LS tok, int iOpeningTag) {
4  
  S tag = getTag(tok.get(iOpeningTag));
5  
  S closingTag = "/" + tag;
6  
  ifdef findClosingTag_debug
7  
    print("findClosingTag: tag=" + tag);
8  
  endifdef
9  
  int level = 1;
10  
  for (int i = iOpeningTag+2; i < l(tok); i += 2) {
11  
    S t = tok.get(i);
12  
    S tag2 = getTag(t);
13  
    ifdef findClosingTag_debug
14  
      printVars_str("findClosingTag", +tag2, +t);
15  
    endifdef
16  
    if (eqic(tag2, tag))
17  
      ++level;
18  
    else if (eqic(tag2, closingTag)) {
19  
      --level;
20  
      ifdef findClosingTag_debug
21  
        printVars_str("findClosingTag", +level);
22  
      endifdef
23  
      if (level == 0)
24  
        ret i;
25  
    }
26  
  }
27  
  ret l(tok);
28  
}

Author comment

Began life as a copy of #1007927

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1029889
Snippet name: findClosingTag
Eternal ID of this version: #1029889/5
Text MD5: 90ecccd62336bc8d517c09a578e38fb4
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-09-27 19:08:22
Source code size: 763 bytes / 28 lines
Pitched / IR pitched: No / No
Views / Downloads: 193 / 284
Version history: 4 change(s)
Referenced in: [show references]