Skip to content
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

Trim the newline right before the end-delimiter in multi-line strings. #318

Closed
ghost opened this issue Apr 9, 2015 · 3 comments
Closed

Comments

@ghost
Copy link

ghost commented Apr 9, 2015

Although you (the owners?) had decided not to trim the last newline in #225 , I'm still not for it. I'd like to make the newline “obvious”. E.g.

key = '''

Just a sentence.

'''

is equal to key = """\nJust a sentence.\n""". Is it really counter-intuitive?

And a special case:

# key = "\n"
key = """

"""
@ghost ghost changed the title Trim the last newline in multi-line strings. Trim the newline right before the end-delimiter in multi-line strings. Apr 9, 2015
@rmunn
Copy link

rmunn commented Feb 22, 2017

To me, yes, what you are suggesting would be counter-intuitive. Trimming the leading newline is also slightly counter-intuitive, but the value of "all column-1 text can start on column 1 of the file" is greater than that counter-intuitiveness. But in your "Just a sentence" example, my brain expects to see two newlines at the end, because there's a blank line there before the closing delimiter. The absence of that second newline would bother me immensely, as would the absence of a final newline in this example:

key = """
Just a sentence.
"""

If I wanted to have no newline at the end of that example, I would have put the closing tag immediately after the period -- and, in fact, I would have simply written "Just a sentence." on a single line in that case. If TOML stripped the newline that I intended to be there, I would be surprised and annoyed.

@a-teammate a-teammate mentioned this issue Oct 14, 2017
26 tasks
@mk-pmb
Copy link

mk-pmb commented Nov 5, 2017

Think about indentation, or you'll repeat the ugliness of "here documents" taught in too many bash tutorials:

function ugly () {
  ( foo_header
    foo_content_escape <<EndOfContent
      Hello world, indentation is great!
      Unfortunately, most tutorials make it
      look like it's not allowed here:
EndOfContent
    foo_trailer
    ) | tr A-Z a-z
}

In bash and dash, fortunately, you can cheat by making the exact amount of whitespace part of your marker (which you'll then have to quote). In TOML however, you can't choose the marker.

@pradyunsg
Copy link
Member

I think this issue can be closed:

  1. The OP is now, @ghost.
  2. For the times when you don't want a newline at the start, you can put a \ after the opening quotes.

@mojombo mojombo closed this as completed Feb 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@mojombo @rmunn @pradyunsg @mk-pmb and others