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

31
LINES

< > BotCompany Repo | #1008782 // dynamize_noEncode - turn snippet IDs into links

JavaX fragment (include)

1  
ifdef IntelligenceMachine
2  
sbool dynamize_doGlobalIDs;
3  
endifdef
4  
static ThreadLocal<O[]> dynamize_linkParams = new ThreadLocal;
5  
6  
sS dynamize_noEncode(S html) {
7  
  L<S> tok = htmlTok(html);
8  
  Pattern p = Pattern.compile(regexp_findSnippetIDs());
9  
  for (int i = 0; i < l(tok); i += 2) {
10  
    Matcher m = p.matcher(tok.get(i).replace("&#", "&~~~"));
11  
    new StringBuffer buf;
12  
    while (m.find()) {
13  
      S id = m.group(1);
14  
      S link = m.group();
15  
      pcall {
16  
        link = ahref(snippetLink(id), link,
17  
          concatArrays(new O[] {title := getSnippetTitle_cached(id)}, dynamize_linkParams!));
18  
      }
19  
      mreplace(m, buf, link);
20  
    }
21  
    m.appendTail(buf);
22  
    S s = str(buf).replace("&~~~", "&#");
23  
    ifdef IntelligenceMachine
24  
      if (dynamize_doGlobalIDs)
25  
        s = dynamizeGlobalIDsInHTML(s);
26  
    endifdef
27  
    tok.set(i, s);
28  
  }
29  
  dynamize_linkParams.set(null);
30  
  ret join(tok);
31  
}

Author comment

Began life as a copy of #1003240

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: #1008782
Snippet name: dynamize_noEncode - turn snippet IDs into links
Eternal ID of this version: #1008782/17
Text MD5: 96111ee04f765f7798eb4679dbf2df6f
Author: stefan
Category: javax / html
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-11-20 01:04:57
Source code size: 923 bytes / 31 lines
Pitched / IR pitched: No / No
Views / Downloads: 580 / 648
Version history: 16 change(s)
Referenced in: [show references]