-
Notifications
You must be signed in to change notification settings - Fork 859
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
Add mult-line and literal strings #232
Conversation
LGTM. |
@wycats I'd love your input on this one, if you have a minute. It's a significant (but backwards compatible) addition to the spec. |
@mojombo I took a look and this seems pretty reasonable. I wonder if the difference between single- and double-quoted strings is too subtle, but Toml is a pretty simple language and people can read the docs if they're confused.
I assume this doesn't mean to disallow UTF-8 encoded Unicode characters?
I'm inclined to suggest the same treatment for a trailing newline to enable: key3 = """
One
Two
"""
An alternative solution to this problem would be to allow two adjacent
Typo in One specific use-case worth considering explicitly is shell-escaping in commands embedded in string literals. I think that single-quote raw strings solve this use-case. |
I'm not really a fan of trimming the trailing new line since it isn't usually what you want. If we did, the common case would be: key3 = """
One
Two
""" I'm pretty ambivalent about |
@BurntSushi Sounds fine re: trailing newline. I don't see a good reason not to allow |
I don't think the "double On the other hand, allowing |
One issue that might deserve an explicit clarification is whether, if a triple-quoted strings ends with 4 or 5 quotes, the first 1 or 2 of them are part of the content of the string. If yes, the string
could be written like this:
If not, the final quote must be escaped. That's what Python seems to expect. I'm not biased on way or the other but think a clarification would be in order to help parser writers. |
Correct. The intention is that any UTF-8 encoded character is ok to use except those explicitly mentioned.
I'd prefer to keep literal strings 100% literal. It makes it easier to decide which string type to use. It also prevents any ambiguities, for instance, what does
I think it's reasonable and straightforward to require that quotes be escaped in that scenario. The delimiter is Any other final concerns from anyone? I'd like to merge this soon. |
@ChristianSi I just pushed a commit (7f33170) that should address the quotation mark escaping you brought up. |
@mojombo 👍 |
1 similar comment
@mojombo 👍 |
Add multi-line and literal strings
Merged! |
Extension of #228.
"""\
as opening delimiter for multi-line basic strings.