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

25
LINES

< > BotCompany Repo | #1021533 // parseColonProperties_withMultiLines

JavaX fragment (include)

static SS parseColonProperties_withMultiLines(S text) {
  ret parseColonProperties_withMultiLines(text, new LinkedHashMap);
}

static SS parseColonProperties_withMultiLines(S text, SS map) {
  LS lines = lines(text);
  int n = l(lines);
  for iLine to n: {
    S s = trim(lines.get(iLine));
    int i = indexOf(s, ':');
    if (i > 0) {
      if (endsWith(s, ':')) {
        S key = trim(dropLast(s));
        int j = iLine+1;
        while (j < n && emptyAfterTrim(lines.get(j))) ++j;
        int k = j;
        while (j < n && !emptyAfterTrim(lines.get(j))) ++j;
        map.put(key, joinLines(subList(lines, k, j)));
        iLine = j;
      } else
        map.put(trimSubstring(s, 0, i), trimSubstring(s, i+1));
    }
  }
  ret map;
}

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: 319 / 374
Version history: 5 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)