index.d.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import type {Data, Literal} from 'mdast'
  2. export {mathFromMarkdown, mathToMarkdown} from './lib/index.js'
  3. export type {ToOptions} from './lib/index.js'
  4. /**
  5. * Math (flow).
  6. */
  7. export interface Math extends Literal {
  8. /**
  9. * Node type of math (flow).
  10. */
  11. type: 'math'
  12. /**
  13. * Custom information relating to the node.
  14. */
  15. meta?: string | null | undefined
  16. /**
  17. * Data associated with the mdast math (flow).
  18. */
  19. data?: MathData | undefined
  20. }
  21. /**
  22. * Info associated with mdast math (flow) nodes by the ecosystem.
  23. */
  24. export interface MathData extends Data {}
  25. /**
  26. * Math (text).
  27. */
  28. export interface InlineMath extends Literal {
  29. /**
  30. * Node type of math (text).
  31. */
  32. type: 'inlineMath'
  33. /**
  34. * Data associated with the mdast math (text).
  35. */
  36. data?: InlineMathData | undefined
  37. }
  38. /**
  39. * Info associated with mdast math (text) nodes by the ecosystem.
  40. */
  41. export interface InlineMathData extends Data {}
  42. // Add custom data tracked to turn markdown into a tree.
  43. declare module 'mdast-util-from-markdown' {
  44. interface CompileData {
  45. /**
  46. * Whether we’re in math (flow).
  47. */
  48. mathFlowInside?: boolean | undefined
  49. }
  50. }
  51. // Add custom data tracked to turn a tree into markdown.
  52. declare module 'mdast-util-to-markdown' {
  53. interface ConstructNameMap {
  54. /**
  55. * Math (flow).
  56. *
  57. * ```markdown
  58. * > | $$
  59. * ^^
  60. * > | a
  61. * ^
  62. * > | $$
  63. * ^^
  64. * ```
  65. */
  66. mathFlow: 'mathFlow'
  67. /**
  68. * Math (flow) meta flag.
  69. *
  70. * ```markdown
  71. * > | $$a
  72. * ^
  73. * | b
  74. * | $$
  75. * ```
  76. */
  77. mathFlowMeta: 'mathFlowMeta'
  78. }
  79. }
  80. // Add nodes to tree.
  81. declare module 'mdast' {
  82. interface BlockContentMap {
  83. math: Math
  84. }
  85. interface PhrasingContentMap {
  86. inlineMath: InlineMath
  87. }
  88. interface RootContentMap {
  89. inlineMath: InlineMath
  90. math: Math
  91. }
  92. }