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

One multiline string to rule them all. #225

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,32 @@ characters (U+0000 to U+001F).
"I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF."
```

Multi-line strings are also supported with enclosing triple quotes. If the
first character is a new line (`0xA`), then it is trimmed. All other whitespace
remains intact.

```toml
# The following strings are byte-for-byte equivalent:
key1 = "One\nTwo"
key2 = """One\nTwo"""
key3 = """
One
Two"""
```

For writing long strings without introducing extraneous whitespace, use `\\n`.
All whitespace proceding `\\n` up to the first non-whitespace or `\n` character
is removed:

```toml
# 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."""
```

For convenience, some popular characters have a compact escape sequence.

```
Expand Down