Support multi-line basic strings
Closed this issue · 0 comments
From TOML 0.3.1 specification:
Multi-line basic strings are surrounded by three quotation marks on each side and allow newlines. A newline immediately following the opening delimiter will be trimmed. All other whitespace and newline characters remain intact.
key1 = """
Roses are red
Violets are blue"""
TOML parsers should feel free to normalize newline to whatever makes sense for their platform.
# On a Unix system, the above multi-line string will most likely be the same as:
key2 = "Roses are red\nViolets are blue"
# On a Windows system, it will most likely be equivalent to:
key3 = "Roses are red\r\nViolets are blue"
For writing long strings without introducing extraneous whitespace, end a line with a . The \ will be trimmed along with all whitespace (including newlines) up to the next non-whitespace character or closing delimiter. If the first characters after the opening delimiter are a backslash and a newline, then they will both be trimmed along with all whitespace and newlines up to the next non-whitespace character or closing delimiter. All of the escape sequences that are valid for basic strings are also valid for multi-line basic strings.
# The following strings are byte-for-byte equivalent:
key1 = "The quick brown fox jumps over the lazy dog."
key2 = """
The quick brown \
fox jumps over \
the lazy dog."""
key3 = """\
The quick brown \
fox jumps over \
the lazy dog.\
"""