/** * Stringify an XML document object into a XML string. * @module */ import type { Nullable, stringifyable, xml_document, xml_node, xml_text } from "./_types.js"; export type { Nullable, stringifyable, xml_document, xml_node, xml_text }; /** XML stringifier options. */ export type options = { /** Format options. */ format?: { /** * Indent string (defaults to `" "`). * Set to empty string to disable indentation and enable minification. */ indent?: string; /** Break text node if its length is greater than this value (defaults to `128`). */ breakline?: number; }; /** Replace options. */ replace?: { /** * Force escape all XML entities. * By default, only the ones that would break the XML structure are escaped. */ entities?: boolean; /** * Custom replacer (this is applied after other revivals). * When it is applied on an attribute, `key` and `value` will be given. * When it is applied on a node, both `key` and `value` will be `null`. * Return `undefined` to delete either the attribute or the tag. */ custom?: (args: { name: string; key: Nullable; value: Nullable; node: Readonly; }) => unknown; }; }; /** XML stringifier options (with non-nullable format options). */ type _options = options & { format: NonNullable; }; /** * Stringify an {@link xml_document} object into a XML string. * * Output can be customized using the {@link options} parameter. * * ```ts * import { stringify } from "./stringify.ts" * * console.log(stringify({ * "@version": "1.0", * "@standalone": "yes", * root: { * text: "hello", * array: ["world", "monde", "δΈ–η•Œ", "🌏"], * number: 42, * boolean: true, * complex: { * "@attribute": "value", * "#text": "content", * }, * } * })) * ``` */ export declare function stringify(document: stringifyable, options?: options): string; /** * Helper to create a CDATA node. * * ```ts * import { stringify, cdata } from "./stringify.ts" * stringify({ string: cdata(`hello `) }) * // ]]> * ``` */ export declare function cdata(text: string): Omit; /** * Helper to create a comment node. * * ```ts * import { stringify, comment } from "./stringify.ts" * stringify({ string: comment(`hello world`) }) * // * ``` */ export declare function comment(text: string): Omit; /** Create XML node. */ declare function xml_node(node: xml_node, { format: { breakline, indent }, replace, depth }: _options & { depth?: number; }): string; //# sourceMappingURL=stringify.d.ts.map