PureXML/Sources/Emitting/Options.swift
Mihaela Mihaljevic 708390242c chore: scaffold PureXML pure-Swift XML package
Root Swift package mirroring PureYAML's structure, rules, and verification
gates. Includes the XML node model (Node, Element, Attribute, QualifiedName),
a working emitter (Serializer) with escaping and pretty/compact options, and
structural validation. The parser surface is stable; parse() raises
notImplemented until the scanner lands, pinned by a test.

- dependency-free, namespaced under PureXML
- portability and style gates carried over (style, namespacing, forbidden
  patterns, swiftformat, swiftlint, linux, wasm, windows CI)
- 11 tests passing
2026-06-07 23:20:20 +02:00

29 lines
1.1 KiB
Swift

public extension PureXML.Emitting {
/// Explicit emitter options. The default is pretty-printed output with
/// two-space indentation and a self-closing tag for empty elements.
struct Options: Equatable, Hashable, Sendable {
/// Whether to indent nested elements onto their own lines.
public var prettyPrint: Bool
/// The indentation unit used when ``prettyPrint`` is enabled.
public var indent: String
/// Whether childless elements collapse to `<name/>`.
public var selfCloseEmptyElements: Bool
public init(
prettyPrint: Bool = true,
indent: String = " ",
selfCloseEmptyElements: Bool = true,
) {
self.prettyPrint = prettyPrint
self.indent = indent
self.selfCloseEmptyElements = selfCloseEmptyElements
}
/// Pretty-printed output with two-space indentation.
public static let `default` = Options()
/// Single-line output with no inserted whitespace.
public static let compact = Options(prettyPrint: false)
}
}