docs(encoder): correct the multi-line string claim
Assisted-by: DeepSeek V4.1 Flash
This commit is contained in:
+3
-4
@@ -412,10 +412,9 @@ omitted, because TOML forbids an empty `[[a]]`. Other empty arrays emit as
|
|||||||
### Long strings
|
### Long strings
|
||||||
|
|
||||||
By default every string is emitted as a basic `"..."` string with the escapes
|
By default every string is emitted as a basic `"..."` string with the escapes
|
||||||
TOML requires, and a string containing a newline is emitted as an escaped
|
TOML requires, a newline among them as `\n`. `UseLiteralMultiline(threshold)`
|
||||||
multi-line basic string. `UseLiteralMultiline(threshold)` switches strings that
|
switches strings that contain a newline and are at least `threshold` bytes long
|
||||||
contain a newline and are at least `threshold` bytes long to the literal
|
to the literal `'''...'''` form, which carries the newlines verbatim:
|
||||||
`'''...'''` form, which carries the newlines verbatim:
|
|
||||||
|
|
||||||
```go
|
```go
|
||||||
out, err := interpres.NewEncoder().UseLiteralMultiline(80).Marshal(cfg)
|
out, err := interpres.NewEncoder().UseLiteralMultiline(80).Marshal(cfg)
|
||||||
|
|||||||
+4
-4
@@ -261,14 +261,14 @@ func MarshalContext(ctx context.Context, v any) ([]byte, error) {
|
|||||||
|
|
||||||
// An Encoder encodes Go values into TOML.
|
// An Encoder encodes Go values into TOML.
|
||||||
//
|
//
|
||||||
// All options default to behaviour that preserves byte-for-byte compatibility
|
// All options default to the behaviour earlier releases used, and the defaults
|
||||||
// with previous releases and passes the toml-test compliance suite:
|
// pass the toml-test compliance suite in both directions:
|
||||||
//
|
//
|
||||||
// GroupByKind: true (scalars first, then tables, then arrays of tables)
|
// GroupByKind: true (scalars first, then tables, then arrays of tables)
|
||||||
// OmitEmptyArrays: false (a nil/empty []string slice emits [] as a value;
|
// OmitEmptyArrays: false (a nil/empty []string slice emits [] as a value;
|
||||||
// a nil/empty []Item struct slice is still skipped)
|
// a nil/empty []Item struct slice is still skipped)
|
||||||
// LiteralMultilineAt: 0 (always emit basic multi-line strings with
|
// LiteralMultilineAt: 0 (always emit the escaped basic form, never a
|
||||||
// escape sequences, never literal ones)
|
// literal one)
|
||||||
//
|
//
|
||||||
// Use the chainable option methods to opt out. The option state is private;
|
// Use the chainable option methods to opt out. The option state is private;
|
||||||
// callers that need the underlying knobs reach for the methods rather than
|
// callers that need the underlying knobs reach for the methods rather than
|
||||||
|
|||||||
Reference in New Issue
Block a user