fix(encode): fall back from the literal multiline form when unsafe

Assisted-by: GLM 5.3
This commit is contained in:
2026-09-17 23:06:25 +02:00
parent feef4fe9ea
commit ec0d7a0023
4 changed files with 69 additions and 2 deletions
+4 -1
View File
@@ -351,7 +351,10 @@ out, err := interpres.NewEncoder().UseLiteralMultiline(80).Marshal(cfg)
```
Single-line strings keep the basic form regardless of the threshold, and a
threshold of `0` or less disables the option.
threshold of `0` or less disables the option. A string the literal form cannot
carry verbatim (an embedded run of three single quotes, a control character
other than tab, or a carriage return outside a CRLF pair) also keeps the basic
form, so the output always re-parses to the same value.
### Cancellation