Libraryless. Click here for Pure Java version (2499L/16K).
/* input e.g. [[ prelude title ----- text title 2 ------- text ]] */ static SS underlinedHeadingSections(S text) { LS lines = lines(text); L<Int> l = indicesOfStartingWithTrim(lines, "--"); new LinkedHashMap<S> out; if (nempty(l)) mapPutIfNemptyValue(out, "", rtrim(lines(takeFirst(lines, first(l)-1)))); for i over l: { int i1 = get(l, i); int i2 = or(get(l, i+1), l(lines)+1); S heading = trim(get(lines, i1-1)); out.put(heading, lines(subList(lines, i1+1, i2-1))); } ret out; }
Began life as a copy of #1021250
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1027381 |
| Snippet name: | underlinedHeadingSections |
| Eternal ID of this version: | #1027381/5 |
| Text MD5: | eea379a29a0b94fb0c8c7499c9b5fb9e |
| Transpilation MD5: | 28319a6854509edcf60c1f0c9fceb438 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-03-16 14:21:03 |
| Source code size: | 546 bytes / 28 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 434 / 583 |
| Version history: | 4 change(s) |
| Referenced in: | [show references] |