Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
mlin committed Nov 24, 2022
1 parent 3a4b5b4 commit e68f8b3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions WDL/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,16 @@ def _preprocess_multistring(self, meta, parts):
if parts[-2] and parts[-2][-1] == "\n":
parts[-2] = parts[-2][:-1]
# Detect common leading whitespace on the remaining non-blank lines. For this purpose,
# use a pseudo-string with dummy "~{}" subsituted for placeholders in the expression tree,
# which is simpler than tracking how newlines intersperse with the placeholders.
# use a pseudo-string with dummy "~{}" substituted for placeholders, which is simpler than
# tracking how newlines intersperse with the placeholders in the AST.
common_ws = None
pseudo = "".join((part if isinstance(part, str) else "~{}") for part in parts[1:-1])
for line in pseudo.split("\n"):
line_ws = len(line) - len(line.lstrip())
if line_ws < len(line):
common_ws = line_ws if common_ws is None else min(line_ws, common_ws)
# Remove the common leading whitespace. Here, we do need careful bookkeeping around
# placeholders.
# placeholders in the AST.
if common_ws is not None and common_ws > 0:
at_new_line = True
for i in range(1, len(parts) - 1):
Expand Down

0 comments on commit e68f8b3

Please sign in to comment.