index.d.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. import type {Program} from 'estree-jsx'
  2. import type {Data as HastData, Literal as HastLiteral} from 'hast'
  3. import type {Data as MdastData, Literal as MdastLiteral} from 'mdast'
  4. export {
  5. mdxExpressionFromMarkdown,
  6. mdxExpressionToMarkdown
  7. } from './lib/index.js'
  8. /**
  9. * MDX expression node, occurring in flow (block).
  10. */
  11. export interface MdxFlowExpression extends MdastLiteral {
  12. /**
  13. * Node type.
  14. */
  15. type: 'mdxFlowExpression'
  16. /**
  17. * Data associated with the mdast MDX expression (flow).
  18. */
  19. data?: MdxFlowExpressionData | undefined
  20. }
  21. /**
  22. * Info associated with mdast MDX expression (flow) nodes by the ecosystem.
  23. */
  24. export interface MdxFlowExpressionData extends MdastData {
  25. /**
  26. * Program node from estree.
  27. */
  28. estree?: Program | null | undefined
  29. }
  30. /**
  31. * MDX expression node, occurring in text (phrasing).
  32. */
  33. export interface MdxTextExpression extends MdastLiteral {
  34. /**
  35. * Node type.
  36. */
  37. type: 'mdxTextExpression'
  38. /**
  39. * Data associated with the mdast MDX expression (text).
  40. */
  41. data?: MdxTextExpressionData | undefined
  42. }
  43. /**
  44. * Info associated with mdast MDX expression (text) nodes by the ecosystem.
  45. */
  46. export interface MdxTextExpressionData extends MdastData {
  47. /**
  48. * Program node from estree.
  49. */
  50. estree?: Program | null | undefined
  51. }
  52. /**
  53. * MDX expression node, occurring in flow (block), for hast.
  54. */
  55. export interface MdxFlowExpressionHast extends HastLiteral {
  56. /**
  57. * Node type.
  58. */
  59. type: 'mdxFlowExpression'
  60. /**
  61. * Data associated with the hast MDX expression (flow).
  62. */
  63. data?: MdxFlowExpressionHastData | undefined
  64. }
  65. /**
  66. * Info associated with hast MDX expression (flow) nodes by the ecosystem.
  67. */
  68. export interface MdxFlowExpressionHastData extends HastData {
  69. /**
  70. * Program node from estree.
  71. */
  72. estree?: Program | null | undefined
  73. }
  74. /**
  75. * MDX expression node, occurring in text (phrasing), for hast.
  76. */
  77. export interface MdxTextExpressionHast extends HastLiteral {
  78. /**
  79. * Node type.
  80. */
  81. type: 'mdxTextExpression'
  82. /**
  83. * Data associated with the hast MDX expression (text).
  84. */
  85. data?: MdxTextExpressionHastData | undefined
  86. }
  87. /**
  88. * Info associated with hast MDX expression (text) nodes by the ecosystem.
  89. */
  90. export interface MdxTextExpressionHastData extends HastData {
  91. /**
  92. * Program node from estree.
  93. */
  94. estree?: Program | null | undefined
  95. }
  96. // Add nodes to mdast content.
  97. declare module 'mdast' {
  98. interface RootContentMap {
  99. /**
  100. * MDX expression node, occurring in text (phrasing).
  101. */
  102. mdxTextExpression: MdxTextExpression
  103. /**
  104. * MDX expression node, occurring in flow (block).
  105. */
  106. mdxFlowExpression: MdxFlowExpression
  107. }
  108. interface PhrasingContentMap {
  109. /**
  110. * MDX expression node, occurring in text (phrasing).
  111. */
  112. mdxTextExpression: MdxTextExpression
  113. }
  114. interface BlockContentMap {
  115. /**
  116. * MDX expression node, occurring in flow (block).
  117. */
  118. mdxFlowExpression: MdxFlowExpression
  119. }
  120. }
  121. // Add nodes to hast content.
  122. declare module 'hast' {
  123. interface RootContentMap {
  124. /**
  125. * MDX expression node, occurring in flow (block).
  126. */
  127. mdxFlowExpression: MdxFlowExpressionHast
  128. /**
  129. * MDX expression node, occurring in text (phrasing).
  130. */
  131. mdxTextExpression: MdxTextExpressionHast
  132. }
  133. interface ElementContentMap {
  134. /**
  135. * MDX expression node, occurring in flow (block).
  136. */
  137. mdxFlowExpression: MdxFlowExpressionHast
  138. /**
  139. * MDX expression node, occurring in text (phrasing).
  140. */
  141. mdxTextExpression: MdxTextExpressionHast
  142. }
  143. }