Dedent() remove surrounding newlines #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Breaking change! I realise that this would be a breaking change that you might not desire. I'm happy using my fork of this library for my own projects, but I wanted to know your thoughts on this, and if you'd be interested in merging it in or altering this to be a backward compatible change (e.g. adding a new method that does the
Dedent
+ newline trimming.)The most common use-case for Dedent() is a situation like:
Most programmers would reasonably expect multiLineString to be equal to
"This is a\nmulti-line string."
Currently Dedent() returns"\nThis is a\nmulti-line string.\n"
. When using raw string syntax, there is currently no good way to specify a multi-line string without a "\n". This commit strips a "\n" prefix and suffix, only if the string has both a "\n" prefix and a "\n" suffix.