-
-
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
\
at EOL should escape all whitespace after it and treat it as a single one
#213
Comments
Rust escapes all whitespace until the next non-whitespace character. fn main() {
dbg!("x\
y\
z\
");
}
In strings, this makes sense, but outside of strings, specifically for the purpose of KDL, I think treating |
Just to be clear, this proposal only applies to quoted string literals in KDL; it doesn't change the behavior of linespace / splitting nodes over multiple lines or anything about how KDL handles syntactic whitespace. The Rust behavior is specifically that a backslash preceding a line break (newline or CRLF) consumes itself, the line break, and all succeeding literal whitespace at the beginning of the next line. I'd propose the simpler, more general rule, which is simply that a backslash consume all literal whitespace that succeeds it. In either cases, they notably only consume literal whitespace; they do not consume escaped whitespace. This means we can write things like:
This is exactly equivalent to:
|
Would a better rule be to consume only the same amount of whitespace, so to cut out the prefix whitespace in vertically aligned columns, but also allow non-prefix whitespace at line beginning
|
This has been merged into the kdl-v2 branch |
in one of their streams, @Lucretiel pointed out that Rust strings let you do this:
I think this is a GREAT compromise for not automatically collecting indentation? I think we should do this too.
My one question is that I'm not 100% sure what Rust itself does, but I think whatever that is, we should probably just copy it.
The text was updated successfully, but these errors were encountered: