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)

ifdef IntelligenceMachine
sbool dynamize_doGlobalIDs;
endifdef
static ThreadLocal<O[]> dynamize_linkParams = new ThreadLocal;

sS dynamize_noEncode(S html) {
  L<S> tok = htmlTok(html);
  Pattern p = Pattern.compile(regexp_findSnippetIDs());
  for (int i = 0; i < l(tok); i += 2) {
    Matcher m = p.matcher(tok.get(i).replace("&#", "&~~~"));
    new StringBuffer buf;
    while (m.find()) {
      S id = m.group(1);
      S link = m.group();
      pcall {
        link = ahref(snippetLink(id), link,
          concatArrays(new O[] {title := getSnippetTitle_cached(id)}, dynamize_linkParams!));
      }
      mreplace(m, buf, link);
    }
    m.appendTail(buf);
    S s = str(buf).replace("&~~~", "&#");
    ifdef IntelligenceMachine
      if (dynamize_doGlobalIDs)
        s = dynamizeGlobalIDsInHTML(s);
    endifdef
    tok.set(i, s);
  }
  dynamize_linkParams.set(null);
  ret join(tok);
}

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: 579 / 647
Version history: 16 change(s)
Referenced in: [show references]