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.

// tok must come from htmlTok
// returns index of closing tag or l(tok)
static int findClosingTag(LS tok, int iOpeningTag) {
  S tag = getTag(tok.get(iOpeningTag));
  S closingTag = "/" + tag;
  ifdef findClosingTag_debug
    print("findClosingTag: tag=" + tag);
  endifdef
  int level = 1;
  for (int i = iOpeningTag+2; i < l(tok); i += 2) {
    S t = tok.get(i);
    S tag2 = getTag(t);
    ifdef findClosingTag_debug
      printVars_str("findClosingTag", +tag2, +t);
    endifdef
    if (eqic(tag2, tag))
      ++level;
    else if (eqic(tag2, closingTag)) {
      --level;
      ifdef findClosingTag_debug
        printVars_str("findClosingTag", +level);
      endifdef
      if (level == 0)
        ret i;
    }
  }
  ret l(tok);
}

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: 119 / 184
Version history: 4 change(s)
Referenced in: [show references]