Libraryless. Click here for Pure Java version (2712L/17K).
1 | // leaves lines enclosed in brackets alone |
2 | sS autoUnindent_honoringBrackets(S s) { |
3 | LS l = lines_honoringBrackets(s); |
4 | if (empty(l)) ret s; |
5 | |
6 | // find indent |
7 | int n = Integer.MAX_VALUE; |
8 | for (S line : l) |
9 | n = min(n, getIndentOfLine(line)); |
10 | if (n == 0) ret s; |
11 | |
12 | // unindent |
13 | int _n = n; |
14 | ret lines_possiblyRTrim(s, map(l, line -> substring(line, _n)); |
15 | } |
Began life as a copy of #1002853
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1025780 |
Snippet name: | autoUnindent_honoringBrackets |
Eternal ID of this version: | #1025780/5 |
Text MD5: | 5dc104b86acb9728f73280e8b034dc41 |
Transpilation MD5: | 901a4eae40b23b6e3425c3f641870c49 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-10-19 16:10:54 |
Source code size: | 382 bytes / 15 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 226 / 333 |
Version history: | 4 change(s) |
Referenced in: | [show references] |