Toml: Long strings without line breaks.

Created on 2 Mar 2013  路  5Comments  路  Source: toml-lang/toml

That point has already been discussed in #92, but it is really its own thing:

What about very long strings that don't contain a carriage return, and can't thus be properly displayed with the triple quote syntax in editors with limited width?

Three solutions were proposed so far:

# Java/Javascript style
key = "First part, " +
      "second part and " + 
      "third part."

# Ignore embedded CR/LF/CLRF
key = "First part, 
second part and
third part"

# C style
key = "First part, "
      "second part and "
      "third part."

I don't like the second style, because it forces you to unindent the text.

I proposed the third style, but I'm now partial to the first one, because it is more explicit. For example, a coma forgotten in an array would trigger a syntax error, rather than concatenate values.

Thoughts?

Most helpful comment

For anybody else. This ended up 4 PRs deep, so to save you some time: https://github.com/toml-lang/toml/pull/232

val = """
This is
a mulitline
string
"""

All 5 comments

Why not just use arrays?

long-string = [
    "Do you see any new lines?",
    "I know I don't.",
    "You're right. Definitely no new lines.",
]

Just about every language has facilities for concatenating a list of strings into one string. (Typically in the language's standard library.)

This supposes that the host application supports that scenario. It may not be the case (a config file user may not have the possibility to change the code).

How about this:

"""
This is a very very very \
long sentence \
that is all \
in one line.
"""

This proposal is discussed further in issue #92.

Closed in favor of moving discussion to #225.

For anybody else. This ended up 4 PRs deep, so to save you some time: https://github.com/toml-lang/toml/pull/232

val = """
This is
a mulitline
string
"""
Was this page helpful?
0 / 5 - 0 ratings

Related issues

clarfonthey picture clarfonthey  路  4Comments

hukkin picture hukkin  路  4Comments

Silentdoer picture Silentdoer  路  4Comments

paiden picture paiden  路  3Comments

keiichiiownsu12 picture keiichiiownsu12  路  4Comments