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

23
LINES

< > BotCompany Repo | #1022449 // equalsSignSectionPairs

JavaX fragment (include)

1  
static L<PairS> equalsSignSectionPairs(S text) {
2  
  LS lines = lines(text);
3  
  L<Int> l = indicesOfStartingWithTrim(lines, "==");
4  
  new L<PairS> out;
5  
  
6  
  // prelude
7  
  if (nempty(l)) {
8  
    S s = rtrim(lines(subList(lines, 0, first(l))));
9  
    if (nempty(s))
10  
      addPair(out, "", s);
11  
  }
12  
  
13  
  for i over l: {
14  
    int i1 = l.get(i);
15  
    int i2 = or(get(l, i+1), l(lines));
16  
    S heading = trim(lines.get(i1));
17  
    int iHeading = 0;
18  
    while (iHeading < l(heading) && heading.charAt(iHeading) == '=') iHeading++;
19  
    heading = trim(substring(heading, iHeading));
20  
    addPair(out, heading, lines(subList(lines, i1+1, i2)));
21  
  }
22  
  ret out;
23  
}

Author comment

Began life as a copy of #1022440

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1022449
Snippet name: equalsSignSectionPairs
Eternal ID of this version: #1022449/1
Text MD5: 43b114da697e9d534e8092dd659dff09
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-17 14:29:59
Source code size: 658 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 267 / 276
Referenced in: [show references]