@readme/markdown 8.2.0 → 8.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/components/Accordion/index.tsx +5 -2
  2. package/components/Anchor.jsx +1 -1
  3. package/components/Callout/index.tsx +5 -4
  4. package/components/Cards/index.tsx +17 -5
  5. package/components/Code/index.tsx +11 -2
  6. package/components/CodeTabs/index.tsx +5 -1
  7. package/components/Columns/index.tsx +7 -6
  8. package/components/Embed/index.tsx +10 -7
  9. package/components/Glossary/index.tsx +8 -4
  10. package/components/HTMLBlock/index.tsx +10 -2
  11. package/components/Heading/index.tsx +6 -2
  12. package/components/Image/index.tsx +15 -13
  13. package/components/Table/index.tsx +2 -2
  14. package/components/Tabs/index.tsx +21 -14
  15. package/components/TailwindRoot/index.tsx +6 -2
  16. package/dist/components/Accordion/index.d.ts +7 -6
  17. package/dist/components/Callout/index.d.ts +2 -2
  18. package/dist/components/Cards/index.d.ts +13 -11
  19. package/dist/components/CodeTabs/index.d.ts +5 -1
  20. package/dist/components/Columns/index.d.ts +6 -7
  21. package/dist/components/Embed/index.d.ts +6 -6
  22. package/dist/components/Glossary/index.d.ts +4 -3
  23. package/dist/components/HTMLBlock/index.d.ts +5 -4
  24. package/dist/components/Heading/index.d.ts +1 -1
  25. package/dist/components/Image/index.d.ts +2 -2
  26. package/dist/components/Table/index.d.ts +2 -2
  27. package/dist/components/Tabs/index.d.ts +5 -6
  28. package/dist/components/TailwindRoot/index.d.ts +5 -4
  29. package/dist/contexts/GlossaryTerms.d.ts +4 -4
  30. package/dist/contexts/index.d.ts +2 -2
  31. package/dist/errors/mdx-syntax-error.d.ts +1 -1
  32. package/dist/example/RenderError.d.ts +5 -4
  33. package/dist/lib/ast-processor.d.ts +5 -5
  34. package/dist/lib/compile.d.ts +3 -4
  35. package/dist/lib/hast.d.ts +1 -1
  36. package/dist/lib/mdast.d.ts +3 -1
  37. package/dist/lib/mdastV6.d.ts +4 -1
  38. package/dist/lib/mdx.d.ts +3 -1
  39. package/dist/lib/plain.d.ts +1 -1
  40. package/dist/lib/run.d.ts +6 -12
  41. package/dist/main.js +24553 -24400
  42. package/dist/main.node.js +22070 -21917
  43. package/dist/main.node.js.map +1 -1
  44. package/dist/processor/compile/callout.d.ts +1 -1
  45. package/dist/processor/compile/code-tabs.d.ts +1 -1
  46. package/dist/processor/compile/compatibility.d.ts +20 -31
  47. package/dist/processor/compile/embed.d.ts +1 -1
  48. package/dist/processor/compile/gemoji.d.ts +1 -1
  49. package/dist/processor/compile/html-block.d.ts +1 -1
  50. package/dist/processor/compile/variable.d.ts +1 -1
  51. package/dist/processor/plugin/toc.d.ts +4 -4
  52. package/dist/processor/transform/callouts.d.ts +2 -1
  53. package/dist/processor/transform/code-tabs.d.ts +1 -1
  54. package/dist/processor/transform/compatability.d.ts +1 -1
  55. package/dist/processor/transform/div.d.ts +1 -1
  56. package/dist/processor/transform/embeds.d.ts +1 -1
  57. package/dist/processor/transform/gemoji+.d.ts +1 -1
  58. package/dist/processor/transform/images.d.ts +1 -1
  59. package/dist/processor/transform/index.d.ts +4 -4
  60. package/dist/processor/transform/inject-components.d.ts +2 -2
  61. package/dist/processor/transform/mdx-to-hast.d.ts +1 -1
  62. package/dist/processor/transform/mermaid.d.ts +1 -1
  63. package/dist/processor/transform/readme-components.d.ts +1 -1
  64. package/dist/processor/transform/readme-to-mdx.d.ts +1 -1
  65. package/dist/processor/transform/tables-to-jsx.d.ts +1 -1
  66. package/dist/processor/transform/tailwind.d.ts +2 -1
  67. package/dist/processor/transform/variables.d.ts +1 -1
  68. package/dist/processor/utils.d.ts +8 -8
  69. package/dist/utils/consts.d.ts +1 -0
  70. package/dist/utils/user.d.ts +2 -2
  71. package/package.json +4 -1
@@ -1,3 +1,3 @@
1
- import { Callout } from '../../types';
1
+ import type { Callout } from '../../types';
2
2
  declare const callout: (node: Callout, _: any, state: any, info: any) => any;
3
3
  export default callout;
@@ -1,3 +1,3 @@
1
- import { CodeTabs } from '../../types';
1
+ import type { CodeTabs } from '../../types';
2
2
  declare const codeTabs: (node: CodeTabs, _: any, state: any, info: any) => any;
3
3
  export default codeTabs;
@@ -1,53 +1,42 @@
1
- import { Html, Image } from 'mdast';
1
+ import type { Html } from 'mdast';
2
+ import type { Figure } from 'types';
2
3
  import { NodeTypes } from '../../enums';
3
- type CompatNodes = {
4
- type: NodeTypes.glossary;
4
+ interface EditorGlossary {
5
+ children: [{
6
+ type: 'text';
7
+ value: string;
8
+ }];
5
9
  data: {
10
+ hName: 'Glossary';
6
11
  hProperties: {
7
12
  term: string;
8
13
  };
9
14
  };
10
- } | {
11
15
  type: NodeTypes.glossary;
16
+ }
17
+ interface CompatEmbed {
12
18
  data: {
13
- hName: 'Glossary';
19
+ hProperties: Record<string, string>;
14
20
  };
15
- children: [{
16
- type: 'text';
17
- value: string;
18
- }];
19
- } | {
20
- type: NodeTypes.reusableContent;
21
- tag: string;
22
- } | {
21
+ html: string;
23
22
  type: 'embed';
23
+ }
24
+ type CompatNodes = CompatEmbed | EditorGlossary | Figure | Html | {
24
25
  data: {
25
26
  hProperties: {
26
- [key: string]: string;
27
+ className: string[];
27
28
  };
28
29
  };
30
+ type: 'i';
31
+ } | {
32
+ tag: string;
33
+ type: NodeTypes.reusableContent;
29
34
  } | {
30
35
  type: 'escape';
31
36
  value: string;
32
- } | {
33
- type: 'figure';
34
- children: [Image, {
35
- type: 'figcaption';
36
- children: [{
37
- type: 'text';
38
- value: string;
39
- }];
40
- }];
41
- } | {
42
- type: 'i';
43
- data: {
44
- hProperties: {
45
- className: string[];
46
- };
47
- };
48
37
  } | {
49
38
  type: 'yaml';
50
39
  value: string;
51
- } | Html;
40
+ };
52
41
  declare const compatibility: (node: CompatNodes) => string;
53
42
  export default compatibility;
@@ -1,3 +1,3 @@
1
- import type { EmbedBlock } from "types";
1
+ import type { EmbedBlock } from 'types';
2
2
  declare const embed: (node: EmbedBlock) => string;
3
3
  export default embed;
@@ -1,3 +1,3 @@
1
- import { Gemoji } from '../../types';
1
+ import type { Gemoji } from '../../types';
2
2
  declare const gemoji: (node: Gemoji) => string;
3
3
  export default gemoji;
@@ -1,3 +1,3 @@
1
- import { HTMLBlock } from '../../types';
1
+ import type { HTMLBlock } from '../../types';
2
2
  declare const htmlBlock: (node: HTMLBlock) => string;
3
3
  export default htmlBlock;
@@ -1,3 +1,3 @@
1
- import { Variable } from '../../types';
1
+ import type { Variable } from '../../types';
2
2
  declare const variable: (node: Variable) => string;
3
3
  export default variable;
@@ -1,8 +1,8 @@
1
- import { Transformer } from 'unified';
2
- import { Root } from 'hast';
3
- import { CustomComponents, IndexableElements } from '../../types';
1
+ import type { CustomComponents, IndexableElements } from '../../types';
2
+ import type { Root } from 'hast';
3
+ import type { Transformer } from 'unified';
4
4
  interface Options {
5
- components?: Record<string, any>;
5
+ components?: CustomComponents;
6
6
  }
7
7
  export declare const rehypeToc: ({ components }: Options) => Transformer<Root, Root>;
8
8
  export declare const tocToMdx: (toc: IndexableElements[], components: CustomComponents) => string;
@@ -1,2 +1,3 @@
1
- declare const calloutTransformer: () => (tree: any) => void;
1
+ import type { Root } from 'mdast';
2
+ declare const calloutTransformer: () => (tree: Root) => void;
2
3
  export default calloutTransformer;
@@ -1,4 +1,4 @@
1
- import { Node } from 'mdast';
1
+ import type { Node } from 'mdast';
2
2
  declare const codeTabsTransformer: ({ copyButtons }?: {
3
3
  copyButtons?: boolean;
4
4
  }) => (tree: Node) => Node;
@@ -1,3 +1,3 @@
1
- import { Transform } from 'mdast-util-from-markdown';
1
+ import type { Transform } from 'mdast-util-from-markdown';
2
2
  declare const compatibilityTransfomer: () => Transform;
3
3
  export default compatibilityTransfomer;
@@ -1,3 +1,3 @@
1
- import { Transform } from 'mdast-util-from-markdown';
1
+ import type { Transform } from 'mdast-util-from-markdown';
2
2
  declare const divTransformer: () => Transform;
3
3
  export default divTransformer;
@@ -1,3 +1,3 @@
1
- import { Node } from 'mdast';
1
+ import type { Node } from 'mdast';
2
2
  declare const embedTransformer: () => (tree: Node) => void;
3
3
  export default embedTransformer;
@@ -1,3 +1,3 @@
1
- import { Root } from 'mdast';
1
+ import type { Root } from 'mdast';
2
2
  declare const gemojiTransformer: () => (tree: Root) => Root;
3
3
  export default gemojiTransformer;
@@ -1,3 +1,3 @@
1
- import { Node } from 'mdast';
1
+ import type { Node } from 'mdast';
2
2
  declare const imageTransformer: () => (tree: Node) => Node;
3
3
  export default imageTransformer;
@@ -6,11 +6,11 @@ import mermaidTransformer from './mermaid';
6
6
  import readmeComponentsTransformer from './readme-components';
7
7
  import readmeToMdx from './readme-to-mdx';
8
8
  import tablesToJsx from './tables-to-jsx';
9
- import variablesTransformer from './variables';
10
9
  import tailwindTransformer from './tailwind';
10
+ import variablesTransformer from './variables';
11
11
  export { compatabilityTransfomer, divTransformer, injectComponents, mdxToHast, mermaidTransformer, readmeComponentsTransformer, readmeToMdx, tablesToJsx, tailwindTransformer, variablesTransformer, };
12
12
  export declare const defaultTransforms: {
13
- calloutTransformer: () => (tree: any) => void;
13
+ calloutTransformer: () => (tree: import("mdast").Root) => void;
14
14
  codeTabsTransformer: ({ copyButtons }?: {
15
15
  copyButtons?: boolean;
16
16
  }) => (tree: import("mdast").Node) => import("mdast").Node;
@@ -18,7 +18,7 @@ export declare const defaultTransforms: {
18
18
  imageTransformer: () => (tree: import("mdast").Node) => import("mdast").Node;
19
19
  gemojiTransformer: () => (tree: import("mdast").Root) => import("mdast").Root;
20
20
  };
21
- declare const _default: ((() => (tree: any) => void) | (({ copyButtons }?: {
21
+ declare const _default: ((() => (tree: import("mdast").Root) => void) | (({ copyButtons }?: {
22
22
  copyButtons?: boolean;
23
- }) => (tree: import("mdast").Node) => import("mdast").Node) | (() => (tree: import("mdast").Node) => void) | (() => (tree: import("mdast").Node) => import("mdast").Node) | (() => (tree: import("mdast").Root) => import("mdast").Root))[];
23
+ }) => (tree: import("mdast").Node) => import("mdast").Node) | (() => (tree: import("mdast").Node) => void) | (() => (tree: import("mdast").Root) => import("mdast").Root) | (() => (tree: import("mdast").Node) => import("mdast").Node))[];
24
24
  export default _default;
@@ -1,5 +1,5 @@
1
- import { MdastComponents } from '../../types';
2
- import { Transform } from 'mdast-util-from-markdown';
1
+ import type { MdastComponents } from '../../types';
2
+ import type { Transform } from 'mdast-util-from-markdown';
3
3
  interface Options {
4
4
  components?: MdastComponents;
5
5
  }
@@ -1,3 +1,3 @@
1
- import { Transform } from 'mdast-util-from-markdown';
1
+ import type { Transform } from 'mdast-util-from-markdown';
2
2
  declare const mdxToHast: () => Transform;
3
3
  export default mdxToHast;
@@ -1,3 +1,3 @@
1
- import { Node } from 'unist';
1
+ import type { Node } from 'unist';
2
2
  declare const mermaidTransformer: () => (tree: Node) => Node;
3
3
  export default mermaidTransformer;
@@ -1,4 +1,4 @@
1
- import { Transform } from 'mdast-util-from-markdown';
1
+ import type { Transform } from 'mdast-util-from-markdown';
2
2
  interface Options {
3
3
  components: Record<string, string>;
4
4
  html?: boolean;
@@ -1,3 +1,3 @@
1
- import { Transform } from 'mdast-util-from-markdown';
1
+ import type { Transform } from 'mdast-util-from-markdown';
2
2
  declare const readmeToMdx: () => Transform;
3
3
  export default readmeToMdx;
@@ -1,3 +1,3 @@
1
- import { Transform } from 'mdast-util-from-markdown';
1
+ import type { Transform } from 'mdast-util-from-markdown';
2
2
  declare const tablesToJsx: () => Transform;
3
3
  export default tablesToJsx;
@@ -1,6 +1,7 @@
1
- import { Plugin } from 'unified';
1
+ import type { Plugin } from 'unified';
2
2
  interface TailwindRootOptions {
3
3
  components: Record<string, string>;
4
+ parseRoot?: boolean;
4
5
  }
5
6
  declare const tailwind: Plugin<[TailwindRootOptions]>;
6
7
  export default tailwind;
@@ -1,4 +1,4 @@
1
- import { Transform } from 'mdast-util-from-markdown';
1
+ import type { Transform } from 'mdast-util-from-markdown';
2
2
  declare const variables: ({ asMdx }?: {
3
3
  asMdx: boolean;
4
4
  }) => Transform;
@@ -1,5 +1,5 @@
1
- import type { Node, Root as MdastRoot, Root } from 'mdast';
2
1
  import type { Root as HastRoot } from 'hast';
2
+ import type { Node, Root as MdastRoot, Root } from 'mdast';
3
3
  import type { MdxJsxFlowElement, MdxJsxTextElement, MdxjsEsm } from 'mdast-util-mdx';
4
4
  import type { MdxJsxAttribute } from 'mdast-util-mdx-jsx';
5
5
  /**
@@ -18,7 +18,7 @@ export declare const formatHProps: <T>(node: Node) => string;
18
18
  * @param {Object} props
19
19
  * @returns {string}
20
20
  */
21
- export declare const formatProps: (props: Object) => string;
21
+ export declare const formatProps: <T>(props: T) => string;
22
22
  /**
23
23
  * Returns the hProperties of a node.
24
24
  *
@@ -34,7 +34,7 @@ export declare const getHProps: <T>(node: Node) => T;
34
34
  * @param {Node} node
35
35
  * @returns {Array} array of hProperty keys
36
36
  */
37
- export declare const getHPropKeys: <T>(node: Node) => any;
37
+ export declare const getHPropKeys: <T>(node: Node) => string[];
38
38
  /**
39
39
  * Gets the attributes of an MDX element and returns them as an object of hProperties.
40
40
  *
@@ -42,7 +42,7 @@ export declare const getHPropKeys: <T>(node: Node) => any;
42
42
  * @param {(MdxJsxFlowElement | MdxJsxTextElement)} jsx
43
43
  * @returns {T} object of hProperties
44
44
  */
45
- export declare const getAttrs: <T>(jsx: MdxJsxFlowElement | MdxJsxTextElement) => any;
45
+ export declare const getAttrs: <T>(jsx: MdxJsxFlowElement | MdxJsxTextElement) => T;
46
46
  /**
47
47
  * Gets the children of an MDX element and returns them as an array of Text nodes.
48
48
  * Currently only being used by the HTML Block component, which only expects a single text node.
@@ -51,7 +51,7 @@ export declare const getAttrs: <T>(jsx: MdxJsxFlowElement | MdxJsxTextElement) =
51
51
  * @param {(MdxJsxFlowElement | MdxJsxTextElement)} jsx
52
52
  * @returns {Array} array of child text nodes
53
53
  */
54
- export declare const getChildren: <T>(jsx: MdxJsxFlowElement | MdxJsxTextElement) => any;
54
+ export declare const getChildren: <T>(jsx: MdxJsxFlowElement | MdxJsxTextElement) => T;
55
55
  /**
56
56
  * Tests if a node is an MDX element.
57
57
  * TODO: Make this more extensible to all types of nodes. isElement(node, 'type' or ['type1', 'type2']), say
@@ -83,8 +83,8 @@ export declare const formatHTML: (html: string) => string;
83
83
  * @param {number} [indent=2]
84
84
  * @returns {string} re-formatted HTML
85
85
  */
86
- export declare const reformatHTML: (html: string, indent?: number) => string;
87
- export declare const toAttributes: (object: Record<string, any>, keys?: string[]) => MdxJsxAttribute[];
86
+ export declare const reformatHTML: (html: string) => string;
87
+ export declare const toAttributes: (object: Record<string, unknown>, keys?: string[]) => MdxJsxAttribute[];
88
88
  /**
89
89
  * Checks if a named export exists in the MDX tree. Accepts either an mdast or
90
90
  * a hast tree.
@@ -97,5 +97,5 @@ export declare const toAttributes: (object: Record<string, any>, keys?: string[]
97
97
  * ```
98
98
  *
99
99
  */
100
- export declare const hasNamedExport: (tree: MdastRoot | HastRoot, name: string) => boolean;
100
+ export declare const hasNamedExport: (tree: HastRoot | MdastRoot, name: string) => boolean;
101
101
  export declare const getExports: (tree: Root) => string[];
@@ -0,0 +1 @@
1
+ export declare const tailwindPrefix = "readme-tailwind";
@@ -1,10 +1,10 @@
1
1
  interface Default {
2
- name: string;
3
2
  default: string;
3
+ name: string;
4
4
  }
5
5
  export interface Variables {
6
- user: Record<string, string>;
7
6
  defaults: Default[];
7
+ user: Record<string, string>;
8
8
  }
9
9
  declare const User: (variables?: Variables) => Record<string, string>;
10
10
  export default User;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@readme/markdown",
3
3
  "description": "ReadMe's React-based Markdown parser",
4
4
  "author": "Rafe Goldberg <rafe@readme.io>",
5
- "version": "8.2.0",
5
+ "version": "8.4.0",
6
6
  "main": "dist/main.node.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "browser": "dist/main.js",
@@ -41,6 +41,7 @@
41
41
  "lodash.kebabcase": "^4.1.1",
42
42
  "mdast-util-find-and-replace": "^3.0.1",
43
43
  "mdast-util-phrasing": "^4.1.0",
44
+ "mdast-util-to-markdown": "^2.1.2",
44
45
  "path-browserify": "^1.0.1",
45
46
  "postcss": "^8.5.1",
46
47
  "postcss-prefix-selector": "^2.1.0",
@@ -53,6 +54,8 @@
53
54
  "remark-gfm": "^4.0.0",
54
55
  "remark-mdx": "^3.0.0",
55
56
  "remark-parse": "^11.0.0",
57
+ "remark-rehype": "^11.1.1",
58
+ "remark-stringify": "^11.0.0",
56
59
  "tailwindcss": "^4.0.3",
57
60
  "unified": "^11.0.4",
58
61
  "unist-util-flatmap": "^1.0.0",