Skip to content

Commit

Permalink
Preserve newline termination (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanno-becker authored Sep 19, 2024
1 parent e08a768 commit 798e30c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions slothy/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,12 @@ def copy(self):
def read_multiline(s, reduce=True):
"""Parse multi-line string or array of strings into list of SourceLine instances"""
if isinstance(s, str):
# Retain newline termination
terminated_by_newline = (len(s) > 0 and s[-1] == '\n')
s = s.splitlines()
if terminated_by_newline:
s.append("")

return SourceLine.merge_escaped_lines([ SourceLine(l, reduce=reduce) for l in s ])

@staticmethod
Expand Down

0 comments on commit 798e30c

Please sign in to comment.