index.d.ts 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /**
  2. * Create an extension for `mdast-util-from-markdown` to enable MDX JSX.
  3. *
  4. * @returns {FromMarkdownExtension}
  5. * Extension for `mdast-util-from-markdown` to enable MDX JSX.
  6. *
  7. * When using the syntax extension with `addResult`, nodes will have a
  8. * `data.estree` field set to an ESTree `Program` node.
  9. */
  10. export function mdxJsxFromMarkdown(): FromMarkdownExtension;
  11. /**
  12. * Create an extension for `mdast-util-to-markdown` to enable MDX JSX.
  13. *
  14. * This extension configures `mdast-util-to-markdown` with
  15. * `options.fences: true` and `options.resourceLink: true` too, do not
  16. * overwrite them!
  17. *
  18. * @param {ToMarkdownOptions | null | undefined} [options]
  19. * Configuration (optional).
  20. * @returns {ToMarkdownExtension}
  21. * Extension for `mdast-util-to-markdown` to enable MDX JSX.
  22. */
  23. export function mdxJsxToMarkdown(options?: ToMarkdownOptions | null | undefined): ToMarkdownExtension;
  24. /**
  25. * Single tag.
  26. */
  27. export type Tag = {
  28. /**
  29. * Name of tag, or `undefined` for fragment.
  30. *
  31. * > 👉 **Note**: `null` is used in the AST for fragments, as it serializes in
  32. * > JSON.
  33. */
  34. name: string | undefined;
  35. /**
  36. * Attributes.
  37. */
  38. attributes: Array<MdxJsxAttribute | MdxJsxExpressionAttribute>;
  39. /**
  40. * Whether the tag is closing (`</x>`).
  41. */
  42. close: boolean;
  43. /**
  44. * Whether the tag is self-closing (`<x/>`).
  45. */
  46. selfClosing: boolean;
  47. /**
  48. * Start point.
  49. */
  50. start: Token["start"];
  51. /**
  52. * End point.
  53. */
  54. end: Token["start"];
  55. };
  56. /**
  57. * Configuration.
  58. */
  59. export type ToMarkdownOptions = {
  60. /**
  61. * Preferred quote to use around attribute values (default: `'"'`).
  62. */
  63. quote?: "\"" | "'" | null | undefined;
  64. /**
  65. * Use the other quote if that results in less bytes (default: `false`).
  66. */
  67. quoteSmart?: boolean | null | undefined;
  68. /**
  69. * Do not use an extra space when closing self-closing elements: `<img/>`
  70. * instead of `<img />` (default: `false`).
  71. */
  72. tightSelfClosing?: boolean | null | undefined;
  73. /**
  74. * Try and wrap syntax at this width (default: `Infinity`).
  75. *
  76. * When set to a finite number (say, `80`), the formatter will print
  77. * attributes on separate lines when a tag doesn’t fit on one line.
  78. * The normal behavior is to print attributes with spaces between them
  79. * instead of line endings.
  80. */
  81. printWidth?: number | null | undefined;
  82. };
  83. import type { Extension as FromMarkdownExtension } from 'mdast-util-from-markdown';
  84. import type { Options as ToMarkdownExtension } from 'mdast-util-to-markdown';
  85. import type { MdxJsxAttribute } from '../index.js';
  86. import type { MdxJsxExpressionAttribute } from '../index.js';
  87. import type { Token } from 'mdast-util-from-markdown';
  88. //# sourceMappingURL=index.d.ts.map