Closed tejassharma96 closed 6 months ago
/// Create `Emitter.Options` with the specified values.
///
/// - parameter canonical: Set if the output should be in the "canonical" format described in the YAML
/// specification.
/// - parameter indent: Set the indentation value.
/// - parameter width: Set the preferred line width. -1 means unlimited.
/// - parameter allowUnicode: Set if unescaped non-ASCII characters are allowed.
/// - parameter lineBreak: Set the preferred line break.
/// - parameter explicitStart: Explicit document start `---`.
/// - parameter explicitEnd: Explicit document end `...`.
/// - parameter version: The `%YAML` directive value or nil.
/// - parameter sortKeys: Set if emitter should sort keys in lexicographic order.
/// - parameter sequenceStyle: Set the style for sequences (arrays / lists)
/// - parameter mappingStyle: Set the style for mappings (dictionaries)
public init(canonical: Bool = false, indent: Int = 0, width: Int = 0, allowUnicode: Bool = false,
lineBreak: Emitter.LineBreak = .ln, version: (major: Int, minor: Int)? = nil,
sortKeys: Bool = false, sequenceStyle: Node.Sequence.Style = .any,
mappingStyle: Node.Mapping.Style = .any, newLineScalarStyle: Node.Scalar.Style = .any) {
Parameters list comments could be updated to have newLineScalarStyle info 🙂
This code:
prints
But when I try to encode something with newlines:
prints
instead of using a multiline literal, it instead encodes them as
\n
. This is confusing, since Yams handles parsing these fine, but is unable to handle encoding them. If you'd like to maintain the current behaviour, I'd suggested adding something like this toEmitter.Options
:Here's a reference on these