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

23
LINES

< > BotCompany Repo | #1025611 // groupPythonStyleIndents_honoringBrackets - TODO: unclosed multi-line string literals

JavaX fragment (include)

/* e.g.
  if (x exists):
    ask (what is x?)
  else:
    ask (does x exist?)
  => a list with two elements
  
  input has to be starting at column 1! (call autoUnindent if unsure)
*/
static LS groupPythonStyleIndents_honoringBrackets(S text) {
  LS lines = lines_honoringBrackets(text);
  new LS out;
  int startOfBlock = 0;
  for i over lines: {
    bool indented = startsWithSpace(lines.get(i));
    if (!indented) {
      addIfNempty(out, lines_rtrim(subList(lines, startOfBlock, i)));
      startOfBlock = i;
    }
  }
  addIfNempty(out, lines_rtrim(subList(lines, startOfBlock)));
  ret out;
}

Author comment

Began life as a copy of #1025586

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: #1025611
Snippet name: groupPythonStyleIndents_honoringBrackets - TODO: unclosed multi-line string literals
Eternal ID of this version: #1025611/2
Text MD5: 1d38048d4060665eb963770be8a69de5
Author: stefan
Category: javax / parsing
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-10-08 13:52:17
Source code size: 621 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 252 / 260
Version history: 1 change(s)
Referenced in: [show references]