From cc6b7708c0595550056240c4519937f8002a52b7 Mon Sep 17 00:00:00 2001 From: Thomas Jollans Date: Sun, 26 May 2024 13:27:59 +0200 Subject: [PATCH] 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 --- SPEC.md | 13 +++++++------ tests/test_cases/input/escaped_whitespace.kdl | 12 ++++++++---- .../input/string_escaped_literal_whitespace.kdl | 6 ++++-- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/SPEC.md b/SPEC.md index e6673d6..26a3ee8 100644 --- a/SPEC.md +++ b/SPEC.md @@ -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, diff --git a/tests/test_cases/input/escaped_whitespace.kdl b/tests/test_cases/input/escaped_whitespace.kdl index 797784a..e4c8b17 100644 --- a/tests/test_cases/input/escaped_whitespace.kdl +++ b/tests/test_cases/input/escaped_whitespace.kdl @@ -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 diff --git a/tests/test_cases/input/string_escaped_literal_whitespace.kdl b/tests/test_cases/input/string_escaped_literal_whitespace.kdl index 1f12126..49fd957 100644 --- a/tests/test_cases/input/string_escaped_literal_whitespace.kdl +++ b/tests/test_cases/input/string_escaped_literal_whitespace.kdl @@ -1,2 +1,4 @@ -node "Hello \ -World \ Stuff" +node " +Hello \ +World \ Stuff +"