Clarify how whitespace escapes work in multi-line strings

One example in the spec and two test cases appeared to contradict the
language of the spec
This commit is contained in:
Thomas Jollans 2024-05-26 13:27:59 +02:00
parent 6a77436e09
commit cc6b7708c0
3 changed files with 19 additions and 12 deletions

13
SPEC.md
View File

@ -386,8 +386,10 @@ such) are retained. For example, these strings are all semantically identical:
```kdl
"Hello\ \nWorld"
"Hello\n\
World"
"
Hello\n\
World
"
"Hello\nWorld"
@ -437,10 +439,9 @@ The string contains the literal characters `hello\n\r\asd"#world`
### Multi-line Strings
When a Quoted or Raw String spans multiple lines with literal, non-escaped
Newlines, it follows a special multi-line syntax that automatically "dedents"
the string, allowing its value to be indented to a visually matching level if
desired.
When a Quoted or Raw String spans multiple lines with literal Newlines, it
follows a special multi-line syntax that automatically "dedents" the string,
allowing its value to be indented to a visually matching level if desired.
A Multi-line string _MUST_ start with a [Newline](#newline) immediately
following its opening `"`. Its final line _MUST_ contain only whitespace,

View File

@ -6,10 +6,14 @@ node \
World
" \
"Hello\n\ \tWorld" \
"Hello\n\
\tWorld" \
"Hello\n\t\
World"
"
Hello\n\
\tWorld
" \
"
Hello\n\t\
World
"
// Note that this file deliberately mixes space and newline indentation for
// test purposes

View File

@ -1,2 +1,4 @@
node "Hello \
World \ Stuff"
node "
Hello \
World \ Stuff
"