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

57
LINES

< > BotCompany Repo | #1030682 // HTMLTokenization - render tokens + spacers in "brickwall" arrangement

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

Transpiled version (3809L) is out of date.

sclass HTMLTokenization {
  S internalID = aRandomID();
  S className = "cnc-" + internalID;
  
  new LS tokensHTML; // need to fill these at least
  new LS spacingsHTML;

  // add params for the div here like style or class
  new MapSO divParams;
  
  S headStuff() { ret ""; }
  
  int nCodeTokens() { ret l(tokensHTML); }
  
  S htmlAndJS() { ret html(); }
  S html() {
    ret hcss(replaceIdentifiers([[
      .className {
        margin: 15px;
        /*flex: 1;*/
        display: inline-grid;
        grid-template-columns: repeat(]] + (nCodeTokens()*2+2) + [[, 1fr);
        /*border: 1px solid;*/
      }
  
      .className div {
        text-align: center;
        box-sizing: border-box;
        grid-column: auto / span 2;
      }
      
      .className .cnc-token {
        border: 1px solid;
        margin: 5px;
      }
  
      .className .cnc-spacing {
        margin: 5px 10px;
        border: 1px dotted gray;
        color: gray;
      }
  
      .className div:nth-child(1),
      .className div:nth-child(]] + (nCodeTokens()+2) + [[) {
        grid-column: auto / span 1
      }
  ]], +className)) + div(
    lines(concatLists(
      ll(div()),
      safeMap(tokensHTML, h -> div(h, class := "cnc-token")),
      ll(div()),
      safeMap(padList(spacingsHTML, nCodeTokens()+1, ""),
        h -> div(h, class := "cnc-spacing"))
    )),
    paramsPlus(divParams, class := className));
  }
}

Author comment

Began life as a copy of #1030661

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1030682
Snippet name: HTMLTokenization - render tokens + spacers in "brickwall" arrangement
Eternal ID of this version: #1030682/10
Text MD5: 69280138051b17bf903d8a5136285db5
Author: stefan
Category: javax / html
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-03-04 14:08:16
Source code size: 1468 bytes / 57 lines
Pitched / IR pitched: No / No
Views / Downloads: 221 / 455
Version history: 9 change(s)
Referenced in: [show references]