Possible wrong values in valid/string/raw-multiline.json
Larpon opened this issue · comments
Hi, thanks for making this test suite!
I'm currently implementing a TOML parser in V and I use this test suite to validate it.
I've come across an oddity in valid/string/raw-multiline.json
.
I believe that the following two test values should start with a \n
char:
"This string\nhas ' a quote character\nand more than\none newline\nin it."
Should be (note the leading \n
)
"\nThis string\nhas ' a quote character\nand more than\none newline\nin it."
and
"This string has a ' quote character."
Should be (note the leading \n
)
"\nThis string has a ' quote character."
The TOML looks like:
oneline = '''This string has a ' quote character.'''
firstnl = '''
This string has a ' quote character.'''
multiline = '''
This string
has ' a quote character
and more than
one newline
in it.'''
both firstnl
and multiline
starts with a line-break?
Since these are multiline literal strings the leading \n
should've been included?
When using multi-line strings (either """ .. """
or ''' .. '''
) the first newline should be trimmed; this is because this is a common pattern for readability:
key = """
Some text
Second line
"""
Otherwise you'd have to write that as:
key = """Some text
Second line
"""
Which is a bit ugly.
See the description in https://toml.io/en/v1.0.0#string :
Multi-line literal strings are surrounded by three single quotes on each side and allow newlines. Like literal strings, there is no escaping whatsoever. A newline immediately following the opening delimiter will be trimmed. All other content between the delimiters is interpreted as-is without modification.
I've somehow missed that.
Thanks for clarifying and sorry for the noise 👍
Sure, no worries.