-
-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow quotes in multi-line strings #419
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -430,7 +430,9 @@ before the closing `"""`. | |
All in-between lines that contain non-newline characters | ||
_MUST_ start with _at least_ the exact same whitespace as the final line | ||
(precisely matching codepoints, not merely counting characters or "size"); | ||
they may contain additional whitesapce following this prefix. | ||
they may contain additional whitesapce following this prefix. The lines in | ||
between may contain unescaped `"` (but no unescaped `"""` as this would close | ||
the string). | ||
|
||
The value of the Multi-Line String omits the first and last Newline, the | ||
Whitespace of the last line, and the matching Whitespace prefix on all | ||
|
@@ -611,10 +613,9 @@ The Raw String variants are indicated by preceding the strings's opening quotes | |
with one or more `#` characters. | ||
The string is then closed by its normal closing quotes, | ||
followed by a _matching_ number of `#` characters. | ||
This means that the string may contain a lone `"` or `"""`, | ||
or `"#`/etc with a _different_ number of `#` characters | ||
than what is used to open the string; | ||
only an exact match actually closes the string. | ||
This means that the string may contain any combination of `"` and `#` characters | ||
other than its closing delimiter (e.g., if a raw string starts with `##"`, it can | ||
contain `"` or `"#`, but not `"##` or `"###`). | ||
|
||
Like other Strings, Raw Strings _MUST NOT_ include any of the [disallowed | ||
literal code-points](#disallowed-literal-code-points) as code points in their | ||
|
@@ -653,7 +654,7 @@ You can show examples of """ | |
without worrying about escapes. | ||
``` | ||
|
||
or equivalently, `#"You can show examples of """\n multi-line strings\n """\nwithout worrying about escapes."#` as a Quoted String. | ||
or equivalently, `"You can show examples of """\n multi-line strings\n """\nwithout worrying about escapes."` as a Quoted String. | ||
|
||
### Number | ||
|
||
|
@@ -856,7 +857,7 @@ disallowed-keyword-identifiers := 'true' - 'false' - 'null' - 'inf' - '-inf' - ' | |
|
||
quoted-string := '"' single-line-string-body '"' | '"""' newline multi-line-string-body newline unicode-space*) '"""' | ||
single-line-string-body := (string-character - newline)* | ||
multi-line-string-body := string-character* | ||
multi-line-string-body := (('"' | '""')? string-character)* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [chefkiss] I love how clean a change this is |
||
string-character := '\' escape | [^\\"] - disallowed-literal-code-points | ||
escape := ["\\bfnrts] | 'u{' hex-digit{1, 6} '}' | (unicode-space | newline)+ | ||
hex-digit := [0-9a-fA-F] | ||
|
1 change: 1 addition & 0 deletions
1
tests/test_cases/expected_kdl/multiline_raw_string_containing_quotes.kdl
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
node "\"\"\"triple-quote\"\"\"\n##\"too few quotes\"##\n#\"\"\"too few #\"\"\"#" |
1 change: 1 addition & 0 deletions
1
tests/test_cases/expected_kdl/multiline_string_containing_quotes.kdl
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
node "this string contains \"quotes\", twice\"\"" |
5 changes: 5 additions & 0 deletions
5
tests/test_cases/input/multiline_raw_string_containing_quotes.kdl
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node ##""" | ||
"""triple-quote""" | ||
##"too few quotes"## | ||
#"""too few #"""# | ||
"""## |
3 changes: 3 additions & 0 deletions
3
tests/test_cases/input/multiline_string_containing_quotes.kdl
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node """ | ||
this string contains "quotes", twice"" | ||
""" |
Oops, something went wrong.
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.
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.
The stuff between backticks is how you would represent the contents as a single line string. I think you’ll want to escape the quotes here.
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.
Fixed