mirror of https://github.com/kdl-org/kdl.git
clarify multi-line strings further
This commit is contained in:
parent
172c67b602
commit
522ce8591e
|
|
@ -54,10 +54,10 @@
|
||||||
* Around `=` for props (`x = 1`)
|
* Around `=` for props (`x = 1`)
|
||||||
* The BOM is now only allowed as the first character in a document. It was
|
* The BOM is now only allowed as the first character in a document. It was
|
||||||
previously treated as generic whitespace.
|
previously treated as generic whitespace.
|
||||||
* Multi-line strings are now automatically dedented, according to the
|
* Multi-line strings are now automatically dedented, according to the common
|
||||||
least-indented line in the body. Multiline strings and raw strings now must
|
whitespace matching the whitespace prefix of the closing line. Multiline
|
||||||
have a newline immediately following their opening `"`, and a final newline
|
strings and raw strings now must have a newline immediately following their
|
||||||
preceding the closing `"`.
|
opening `"`, and a final newline plus whitespace preceding the closing `"`.
|
||||||
* SMALL EQUALS SIGN (`U+FE66`), FULLWIDTH EQUALS SIGN (`U+FF1D`), and HEAVY
|
* SMALL EQUALS SIGN (`U+FE66`), FULLWIDTH EQUALS SIGN (`U+FF1D`), and HEAVY
|
||||||
EQUALS SIGN (`U+1F7F0`) are now treated the same as `=` and can be used for
|
EQUALS SIGN (`U+1F7F0`) are now treated the same as `=` and can be used for
|
||||||
properties (e.g. `お名前=☜(゚ヮ゚☜)`). They are also no longer valid in bare
|
properties (e.g. `お名前=☜(゚ヮ゚☜)`). They are also no longer valid in bare
|
||||||
|
|
|
||||||
61
SPEC.md
61
SPEC.md
|
|
@ -436,30 +436,31 @@ The string contains the literal characters `hello\n\r\asd"#world`
|
||||||
|
|
||||||
### Multi-line Strings
|
### Multi-line Strings
|
||||||
|
|
||||||
When a Quoted or Raw String spans multiple lines with literal, non-escaped Newlines,
|
When a Quoted or Raw String spans multiple lines with literal, non-escaped
|
||||||
it follows a special multi-line syntax
|
Newlines, it follows a special multi-line syntax that automatically "dedents"
|
||||||
that automatically "dedents" the string,
|
the string, allowing its value to be indented to a visually matching level if
|
||||||
allowing its value to be indented to a visually matching level if desired.
|
desired.
|
||||||
|
|
||||||
A Multi-line string _MUST_ start with a [Newline](#newline)
|
A Multi-line string _MUST_ start with a [Newline](#newline) immediately
|
||||||
immediately following its opening `"`.
|
following its opening `"`. Its final line _MUST_ contain only whitespace,
|
||||||
Its final line, preceding the closing `"`,
|
followed by a single closing `"`. All in-between lines that contain
|
||||||
_MUST_ contain only whitespace.
|
non-whitespace characters _MUST_ start with the exact same whitespace as the
|
||||||
All in-between lines that contain non-whitespace characters
|
final line (precisely matching codepoints, not merely counting characters).
|
||||||
_MUST_ start with the exact same whitespace as the final line
|
|
||||||
(precisely matching codepoints, not merely counting characters).
|
|
||||||
|
|
||||||
The value of the Multi-line String omits the first and last Newline,
|
The value of the Multi-line String omits the first and last Newline, the
|
||||||
the Whitespace of the last line,
|
Whitespace of the last line, and the matching Whitespace prefix on all
|
||||||
the matching Whitespace prefix on all intermediate lines,
|
intermediate lines. The first and last Newline can be the same character (that
|
||||||
and all Whitespace on intermediate Whitespace-only lines.
|
is, empty multi-line strings are legal).
|
||||||
The first and last Newline can be the same character
|
|
||||||
(that is, empty multi-line strings are legal).
|
|
||||||
|
|
||||||
Strings with literal Newlines that do not immediately start with a Newline and
|
Strings with literal Newlines that do not immediately start with a Newline and
|
||||||
whose final `"` is not preceeded by optional whitespace and a Newline are illegal.
|
whose final `"` is not preceeded by optional whitespace and a Newline are
|
||||||
|
illegal.
|
||||||
|
|
||||||
In other words, the final line specifies the whitespace prefix that will be removed from all other lines.
|
In other words, the final line specifies the whitespace prefix that will be
|
||||||
|
removed from all other lines.
|
||||||
|
|
||||||
|
It is a syntax error for any body lines of the multi-line string to not match
|
||||||
|
the whitespace prefix of the last line with the final quote.
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
|
|
||||||
|
|
@ -526,6 +527,28 @@ A second indented paragraph.
|
||||||
|
|
||||||
Equivalent to `"Indented a bit.\n\nA second indented paragraph."`
|
Equivalent to `"Indented a bit.\n\nA second indented paragraph."`
|
||||||
|
|
||||||
|
-----------
|
||||||
|
|
||||||
|
The following yield syntax errors:
|
||||||
|
|
||||||
|
```kdl
|
||||||
|
multi-line "
|
||||||
|
closing quote with non-whitespace prefix"
|
||||||
|
```
|
||||||
|
|
||||||
|
```kdl
|
||||||
|
multi-line "stuff
|
||||||
|
"
|
||||||
|
```
|
||||||
|
|
||||||
|
```kdl
|
||||||
|
// Every line must share the exact same prefix as the closing line.
|
||||||
|
multi-line "[\n]
|
||||||
|
[tab]a[\n]
|
||||||
|
[space][space]b[\n]
|
||||||
|
[space][tab][\n]
|
||||||
|
[tab]"
|
||||||
|
```
|
||||||
|
|
||||||
### Number
|
### Number
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
node " hey\n everyone\n how goes?"
|
||||||
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
node " hey\n everyone\n how goes?"
|
||||||
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
node #"
|
||||||
|
hey
|
||||||
|
everyone
|
||||||
|
how goes?
|
||||||
|
"#
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
node #"
|
||||||
|
hey
|
||||||
|
everyone
|
||||||
|
how goes?
|
||||||
|
"#
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
node #"
|
||||||
|
hey
|
||||||
|
everyone
|
||||||
|
how goes?
|
||||||
|
"#
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
node "
|
||||||
|
hey
|
||||||
|
everyone
|
||||||
|
how goes?
|
||||||
|
"
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
node "
|
||||||
|
hey
|
||||||
|
everyone
|
||||||
|
how goes?
|
||||||
|
"
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
node "
|
||||||
|
hey
|
||||||
|
everyone
|
||||||
|
how goes?
|
||||||
|
"
|
||||||
Loading…
Reference in New Issue