index.d.ts 1007 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. declare namespace render {
  2. type Options = {
  3. /**
  4. * Custom single tags (selfClosing).
  5. *
  6. * @default []
  7. */
  8. singleTags: string[] | RegExp[];
  9. /**
  10. * Closing format for single tag.
  11. *
  12. * Formats:
  13. *
  14. * tag: `<br></br>`, slash: `<br />`, default: `<br>`
  15. *
  16. */
  17. closingSingleTag: "tag" | "slash";
  18. /**
  19. * If all attributes should be quoted.
  20. * Otherwise attributes will be unquoted when allowed.
  21. *
  22. * @default true
  23. */
  24. quoteAllAttributes: boolean;
  25. };
  26. // PostHTML Tree
  27. type Tree = Node[];
  28. type Node = NodeText | NodeTag;
  29. type NodeText = string;
  30. type NodeTag = {
  31. tag: string;
  32. attrs?: Attributes;
  33. content?: Node[];
  34. };
  35. type Attributes = Record<string, string>;
  36. }
  37. /**
  38. * Render PostHTML Tree to HTML
  39. * @param tree PostHTML Tree
  40. * @param options Render options
  41. * @returns HTML
  42. */
  43. declare function render(
  44. tree: render.Tree,
  45. options?: Partial<render.Options>
  46. ): string;
  47. export = render;