Use ~~~kdl instead of `` for strings with significant whitespace.

That compiles to <sourcecode> which preserves sequences of spaces.
This commit is contained in:
Jeffrey Yasskin 2025-01-05 22:03:19 -08:00
parent 7a77c4ee81
commit 7f1c8b1aad
1 changed files with 36 additions and 6 deletions

View File

@ -446,8 +446,19 @@ interpreted as described in the following table:
In addition to escaping individual characters, `\` can also escape whitespace.
When a `\` is followed by one or more literal whitespace characters, the `\`
and all of that whitespace are discarded. For example, `"Hello World"` and
`"Hello \ World"` are semantically identical. See whitespace ({{whitespace}})
and all of that whitespace are discarded. For example,
~~~kdl
"Hello World"
~~~
and
~~~kdl
"Hello \ World"
~~~
are semantically identical. See whitespace ({{whitespace}})
and [newlines](#newline) for how whitespace is defined.
Note that only literal whitespace is escaped; whitespace escapes (`\n` and
@ -550,7 +561,12 @@ This is the base indentation
bar
~~~
which is equivalent to `" foo\nThis is the base indentation\n bar"`
which is equivalent to
~~~kdl
" foo\nThis is the base indentation\n bar"
~~~
when written as a single-line string.
#### Shorter last-line indent
@ -574,7 +590,11 @@ This example's string value will be:
bar
~~~
Equivalent to `" foo\n This is no longer on the left edge\n bar"`.
Equivalent to
~~~kdl
" foo\n This is no longer on the left edge\n bar"
~~~
#### Empty lines
@ -596,7 +616,11 @@ Indented a bit.
A second indented paragraph.
~~~
Equivalent to `"Indented a bit.\n\nA second indented paragraph."`
Equivalent to
~~~kdl
"Indented a bit.\n\nA second indented paragraph."
~~~
#### Syntax errors
@ -719,7 +743,13 @@ Here's a """
without escapes.
~~~
or equivalently, `"Here's a \"\"\"\n multiline string\n \"\"\"\nwithout escapes."` as a Quoted String.
or equivalently,
~~~kdl
"Here's a \"\"\"\n multiline string\n \"\"\"\nwithout escapes."
~~~
as a Quoted String.
## Number