A string value may be written as a block of |-lines instead of a quoted literal (the third form in the string diagram):

greeting: |Hello,
          |world!

is the string "Hello,\nworld!\n".

The rules

  • Each source line begins with | — the | is not part of the value.
  • The line's content runs to the end of the line, and a \n is appended for every line, the last included.
  • Escapes are decoded as in a quoted string.
  • A \ immediately before the line break is a continuation: that break is dropped, so the next |-line's content joins without a newline.
  • |-lines must be contiguous — only whitespace (and, in principle, a /* */ block comment closing on the same line before the |) may precede the |. A blank line, a // comment, or any other content ends the block.
  • Because a |-line runs to end-of-line, the separating comma after a block is optional (a comma would otherwise be read as content).
{
  banner: |  ____
          | | fs |
          |  ‾‾‾‾
  motd: |First line, \
        |continued on the same line.
  note: "ordinary string"
}

Round-trip

On write-back the block form is preserved (FSON dialect): the writer re-emits one |-line per newline at the value's indentation — presentation is normalised, content is exact. String::Form::Multiline records the form. Under the JSON / JSON5 writer dialects such a value is written as an ordinary quoted string.

Disabled and keyless

A -- before a |-block disables the whole block. A disabled |-block is the only case where a value may appear with no key — see Disabled members.