-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
strip leading whitespace from triple-quoted strings (closes #70)
For example, s = """ a b """ is now equivalent to "a\n b".
- Loading branch information
Showing
5 changed files
with
97 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1100,6 +1100,8 @@ export | |
|
||
# Macros | ||
@str, | ||
@mstr, | ||
@imstr, | ||
@I_str, | ||
@E_str, | ||
@B_str, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
865ea16
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. This isn't quite the behavior I was thinking of, but it's close. The trailing newline should be kept, so that
Note the newline at the end. Also, with this it is impossible to express intentionally indented text. For example, I would want this:
This can be done by only stripping the whitespace leading up to the closing triple quote. You can merge now though and I can tweak it later. Or we can debate a bit if people strongly disagree.
865ea16
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should it do if the string doesn't end in a newline, e.g.
865ea16
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably use the ident of that line.
865ea16
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, i'll switch to using the last line to strip whitespace, instead of the first.
But i think we should still discard the trailing newline.
865ea16
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Justification? I've found that you almost always want the trailing newline when generating text.
865ea16
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.