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

25
LINES

< > BotCompany Repo | #1021533 // parseColonProperties_withMultiLines

JavaX fragment (include)

1  
static SS parseColonProperties_withMultiLines(S text) {
2  
  ret parseColonProperties_withMultiLines(text, new LinkedHashMap);
3  
}
4  
5  
static SS parseColonProperties_withMultiLines(S text, SS map) {
6  
  LS lines = lines(text);
7  
  int n = l(lines);
8  
  for iLine to n: {
9  
    S s = trim(lines.get(iLine));
10  
    int i = indexOf(s, ':');
11  
    if (i > 0) {
12  
      if (endsWith(s, ':')) {
13  
        S key = trim(dropLast(s));
14  
        int j = iLine+1;
15  
        while (j < n && emptyAfterTrim(lines.get(j))) ++j;
16  
        int k = j;
17  
        while (j < n && !emptyAfterTrim(lines.get(j))) ++j;
18  
        map.put(key, joinLines(subList(lines, k, j)));
19  
        iLine = j;
20  
      } else
21  
        map.put(trimSubstring(s, 0, i), trimSubstring(s, i+1));
22  
    }
23  
  }
24  
  ret map;
25  
}

Author comment

Began life as a copy of #1020412

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: #1021533
Snippet name: parseColonProperties_withMultiLines
Eternal ID of this version: #1021533/6
Text MD5: ce104000e93caf9c387a1a1053148c20
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-02-17 15:03:42
Source code size: 762 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 320 / 375
Version history: 5 change(s)
Referenced in: [show references]