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
Is it good to add short escaping alias \s for space (\u0020)? #622
Comments
I'm a little fond of this idea. It makes spaces explicit. But it's definitely new syntax. And mentally, the notion conflicts with the regular-expression character class " Is there a formulation of this bit of syntax that doesn't conflict with past usages anywhere? |
Or define a line end wrapper character which not output?
Output in JSON: { "sample": "There are \ntwo ways \nto write space \nat line end." } |
Marking as post-1.0 since I don't really have the bandwidth to think about the edge cases here and this isn't super important to get to 1.0. |
Sure, focus on getting 1.0 things done first, we are all looking forward to it, best wishes! |
Even if this is post-1.0, it was supposedly meant to stay open until then? |
@LongTengDao, since this issue is already tagged post-1.0, could you please reopen it? We can effectively ignore it until after 1.0 is released, as I think the issue still bears some examination. You could even argue to remove that tag if you think it's merited. |
I can reopen it now but if it's closed again by OP, I won't be able to reopen. |
Quite confusing if I use regexps in my toml docs (which I do), and having to escape \s as \s. For other escaped chars it's kind of natural to do so since they are generally used well known escapes. The \s to represent a space would be rather unique to TOML (as far as my knowledge goes), which might cause people to trip over it.
|
@mmakaay: For regexes, literal strings might, in any case, be a better fit. |
@ChristianSi @eksortso @pradyunsg Sorry, I see. @mmakaay But the different meaning of |
Let's defer further discussion until after TOML 1.0? Noting a summary for self-reference later. This is a request for an additional compact escape sequence: \s -> U+0020 (space), for easier trailing spaces in multiline strings when trailing spaces are auto-trimmed. It is already possible to denote this as The question to answer here is -- is there enough benefit to adding a compact notation for |
You mean |
Why not just |
A backslash followed by a space is not very visible. I think the point of having the code was to make the character stand out. We could make Granted that's not as small as the proposed two-character |
I'm not so fond of I like the |
The purpose of I think |
@eksortso I second the |
That's true. And doesn't that already solve the original issue? If you're editor is overzealous in removing tailing white space, you can do this: key = """
Alea \
iacta \
est""" |
Not really. The end-of-line backslash strips away all whitespace and all newlines following it before the next non-space, non-linebreak character. That means that subsequent line breaks and indentation at the beginning of the following line gets stripped by the Let's take your example: key = """
Alea \
iacta \
est""" This is equivalent to the one-liner
(Of course, you'll need to highlight that or look at the source to notice the end-of-line spaces.) One way to add a space prominently is with key = """
Alea\u0020
iacta\u0020
est""" If I can get a PR together later today, then (Edit: added in missing spaces to the one-liner.) |
@eksortso, thanks, I didn't think of that. I typically would want to get rid of extraneous whitespace, but I guess there are use cases (like code sections), where that isn't desirable. Still, wanting a space right before a newline seems pretty fringe to me. Nonetheless, short escape codes have a wider use than just spaces, I'd definitely love having that ;) |
Let's add a |
Closing this since the answer to the original question: No. :) #796 can stand on its own, or we can file a dedicated issue for it if it needs extended discussion. |
To avoid spaces at line end in multi-line string being auto trimmed accidentally, and simplify
\u0020
writting.The text was updated successfully, but these errors were encountered: