index.d.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import type {Data, ElementContent, Literal, Properties} from 'hast'
  2. // Expose types.
  3. export type {
  4. FootnoteBackContentTemplate,
  5. FootnoteBackLabelTemplate
  6. } from './lib/footer.js'
  7. export type {Handler, Handlers, Options, State} from './lib/state.js'
  8. // Expose JS API.
  9. export {handlers as defaultHandlers} from './lib/handlers/index.js'
  10. export {
  11. defaultFootnoteBackContent,
  12. defaultFootnoteBackLabel
  13. } from './lib/footer.js'
  14. export {toHast} from './lib/index.js'
  15. /**
  16. * Raw string of HTML embedded into HTML AST.
  17. */
  18. export interface Raw extends Literal {
  19. /**
  20. * Node type of raw.
  21. */
  22. type: 'raw'
  23. /**
  24. * Data associated with the hast raw.
  25. */
  26. data?: RawData | undefined
  27. }
  28. /**
  29. * Info associated with hast raw nodes by the ecosystem.
  30. */
  31. export interface RawData extends Data {}
  32. // Register nodes in content.
  33. declare module 'hast' {
  34. interface ElementData {
  35. /**
  36. * Custom info relating to the node, if `<code>` in `<pre>`.
  37. *
  38. * Defined by `mdast-util-to-hast` (`remark-rehype`).
  39. */
  40. meta?: string | null | undefined
  41. }
  42. interface ElementContentMap {
  43. /**
  44. * Raw string of HTML embedded into HTML AST.
  45. */
  46. raw: Raw
  47. }
  48. interface RootContentMap {
  49. /**
  50. * Raw string of HTML embedded into HTML AST.
  51. */
  52. raw: Raw
  53. }
  54. }
  55. // Register data on mdast.
  56. declare module 'mdast' {
  57. interface Data {
  58. /**
  59. * Field supported by `mdast-util-to-hast` to signal that a node should
  60. * result in something with these children.
  61. *
  62. * When this is defined, when a parent is created, these children will
  63. * be used.
  64. */
  65. hChildren?: ElementContent[] | undefined
  66. /**
  67. * Field supported by `mdast-util-to-hast` to signal that a node should
  68. * result in a particular element, instead of its default behavior.
  69. *
  70. * When this is defined, an element with the given tag name is created.
  71. * For example, when setting `hName` to `'b'`, a `<b>` element is created.
  72. */
  73. hName?: string | undefined
  74. /**
  75. * Field supported by `mdast-util-to-hast` to signal that a node should
  76. * result in an element with these properties.
  77. *
  78. * When this is defined, when an element is created, these properties will
  79. * be used.
  80. */
  81. hProperties?: Properties | undefined
  82. }
  83. }