@readme/markdown 11.12.0 → 11.13.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.
- package/components/Anchor.tsx +10 -1
- package/components/Code/index.tsx +3 -2
- package/components/CodeTabs/index.tsx +31 -12
- package/dist/index.d.ts +1 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/mdxish.d.ts +15 -1
- package/dist/main.js +421 -107
- package/dist/main.node.js +421 -107
- package/dist/main.node.js.map +1 -1
- package/dist/processor/transform/mdxish/mdxish-component-blocks.d.ts +63 -0
- package/dist/processor/transform/mdxish/mdxish-mermaid.d.ts +8 -0
- package/dist/processor/transform/mdxish/retain-boolean-attributes.d.ts +9 -0
- package/package.json +1 -1
|
@@ -1,6 +1,69 @@
|
|
|
1
1
|
import type { Parent } from 'mdast';
|
|
2
2
|
import type { MdxJsxAttribute } from 'mdast-util-mdx-jsx';
|
|
3
3
|
import type { Plugin } from 'unified';
|
|
4
|
+
/**
|
|
5
|
+
* Convert raw attribute string into mdxJsxAttribute entries.
|
|
6
|
+
* Handles both key-value attributes (theme="info") and boolean attributes (empty).
|
|
7
|
+
*/
|
|
4
8
|
export declare const parseAttributes: (raw: string) => MdxJsxAttribute[];
|
|
9
|
+
/**
|
|
10
|
+
* Transform PascalCase HTML nodes into mdxJsxFlowElement nodes.
|
|
11
|
+
*
|
|
12
|
+
* Remark parses unknown/custom component tags as raw HTML nodes.
|
|
13
|
+
* These are the custom readme MDX syntax for components.
|
|
14
|
+
* This transformer identifies these patterns and converts them to proper MDX JSX elements so they
|
|
15
|
+
* can be accurately recognized and rendered later with their component definition code.
|
|
16
|
+
* Though for some tags, we need to handle them specially
|
|
17
|
+
*
|
|
18
|
+
* ## Supported HTML Structures
|
|
19
|
+
*
|
|
20
|
+
* ### 1. Self-closing tags
|
|
21
|
+
* ```
|
|
22
|
+
* <Component />
|
|
23
|
+
* ```
|
|
24
|
+
* Parsed as: `html: "<Component />"`
|
|
25
|
+
*
|
|
26
|
+
* ### 2. Self-contained blocks (entire component in single HTML node)
|
|
27
|
+
* ```
|
|
28
|
+
* <Button>Click me</Button>
|
|
29
|
+
* ```
|
|
30
|
+
* ```
|
|
31
|
+
* <Component>
|
|
32
|
+
* <h2>Title</h2>
|
|
33
|
+
* <p>Content</p>
|
|
34
|
+
* </Component>
|
|
35
|
+
* ```
|
|
36
|
+
* Parsed as: `html: "<Component>\n <h2>Title</h2>\n <p>Content</p>\n</Component>"`
|
|
37
|
+
* The opening tag, content, and closing tag are all captured in one HTML node.
|
|
38
|
+
*
|
|
39
|
+
* ### 3. Multi-sibling components (closing tag in a following sibling)
|
|
40
|
+
* Handles various structures where the closing tag is in a later sibling, such as:
|
|
41
|
+
*
|
|
42
|
+
* #### 3a. Block components (closing tag in sibling paragraph)
|
|
43
|
+
* ```
|
|
44
|
+
* <Callout>
|
|
45
|
+
* Some **markdown** content
|
|
46
|
+
* </Callout>
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* #### 3b. Multi-paragraph components (closing tag several siblings away)
|
|
50
|
+
* ```
|
|
51
|
+
* <Callout>
|
|
52
|
+
*
|
|
53
|
+
* First paragraph
|
|
54
|
+
*
|
|
55
|
+
* Second paragraph
|
|
56
|
+
* </Callout>
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* #### 3c. Nested components split by blank lines (closing tag embedded in HTML sibling)
|
|
60
|
+
* ```
|
|
61
|
+
* <Outer>
|
|
62
|
+
* <Inner>content</Inner>
|
|
63
|
+
*
|
|
64
|
+
* <Inner>content</Inner>
|
|
65
|
+
* </Outer>
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
5
68
|
declare const mdxishComponentBlocks: Plugin<[], Parent>;
|
|
6
69
|
export default mdxishComponentBlocks;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Root } from 'hast';
|
|
2
|
+
/**
|
|
3
|
+
* Rehype plugin for mdxish pipeline to add mermaid-render className to mermaid code blocks.
|
|
4
|
+
* The mermaid-render class is used to identify the mermaid diagrams elements for the
|
|
5
|
+
* mermaid library to transform. See components/CodeTabs/index.tsx for context
|
|
6
|
+
*/
|
|
7
|
+
declare const mdxishMermaidTransformer: () => (tree: Root) => Root;
|
|
8
|
+
export default mdxishMermaidTransformer;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Plugin } from 'unified';
|
|
2
|
+
/**
|
|
3
|
+
* Preserves boolean properties when passed to rehypeRaw because
|
|
4
|
+
* rehypeRaw converts boolean properties in nodes to strings (e.g. true -> ""),
|
|
5
|
+
* which can change the truthiness of the property. Hence we need to preserve the boolean properties.
|
|
6
|
+
*/
|
|
7
|
+
declare const preserveBooleanProperties: Plugin;
|
|
8
|
+
declare const restoreBooleanProperties: Plugin;
|
|
9
|
+
export { preserveBooleanProperties, restoreBooleanProperties };
|
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": "11.
|
|
5
|
+
"version": "11.13.0",
|
|
6
6
|
"main": "dist/main.node.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"browser": "dist/main.js",
|