index.d.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import type { AnyNode } from "domhandler";
  2. export interface DomSerializerOptions {
  3. /**
  4. * Print an empty attribute's value.
  5. *
  6. * @default xmlMode
  7. * @example With <code>emptyAttrs: false</code>: <code>&lt;input checked&gt;</code>
  8. * @example With <code>emptyAttrs: true</code>: <code>&lt;input checked=""&gt;</code>
  9. */
  10. emptyAttrs?: boolean;
  11. /**
  12. * Print self-closing tags for tags without contents.
  13. *
  14. * @default xmlMode
  15. * @example With <code>selfClosingTags: false</code>: <code>&lt;foo&gt;&lt;/foo&gt;</code>
  16. * @example With <code>selfClosingTags: true</code>: <code>&lt;foo /&gt;</code>
  17. */
  18. selfClosingTags?: boolean;
  19. /**
  20. * Treat the input as an XML document; enables the `emptyAttrs` and `selfClosingTags` options.
  21. *
  22. * If the value is `"foreign"`, it will try to correct mixed-case attribute names.
  23. *
  24. * @default false
  25. */
  26. xmlMode?: boolean | "foreign";
  27. /**
  28. * Encode characters that are either reserved in HTML or XML.
  29. *
  30. * If `xmlMode` is `true` or the value not `'utf8'`, characters outside of the utf8 range will be encoded as well.
  31. *
  32. * @default `decodeEntities`
  33. */
  34. encodeEntities?: boolean | "utf8";
  35. /**
  36. * Option inherited from parsing; will be used as the default value for `encodeEntities`.
  37. *
  38. * @default true
  39. */
  40. decodeEntities?: boolean;
  41. }
  42. /**
  43. * Renders a DOM node or an array of DOM nodes to a string.
  44. *
  45. * Can be thought of as the equivalent of the `outerHTML` of the passed node(s).
  46. *
  47. * @param node Node to be rendered.
  48. * @param options Changes serialization behavior
  49. */
  50. export declare function render(node: AnyNode | ArrayLike<AnyNode>, options?: DomSerializerOptions): string;
  51. export default render;
  52. //# sourceMappingURL=index.d.ts.map