@readme/markdown 13.7.0 → 13.7.1
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/dist/index.d.ts +1 -0
- package/dist/main.js +1322 -605
- package/dist/main.node.js +1322 -605
- package/dist/main.node.js.map +1 -1
- package/dist/processor/compile/anchor.d.ts +3 -0
- package/dist/processor/transform/mdxish/magic-blocks/types.d.ts +4 -0
- package/dist/processor/transform/mdxish/mdxish-self-closing-blocks.d.ts +21 -0
- package/enums.ts +20 -0
- package/package.json +13 -11
- package/types.d.ts +281 -0
|
@@ -93,14 +93,18 @@ export interface MagicBlockEmbed {
|
|
|
93
93
|
hName?: string;
|
|
94
94
|
hProperties?: {
|
|
95
95
|
favicon?: string;
|
|
96
|
+
height?: string;
|
|
96
97
|
href?: string;
|
|
97
98
|
html?: string;
|
|
99
|
+
iframe?: boolean;
|
|
98
100
|
image?: string;
|
|
99
101
|
provider?: string;
|
|
100
102
|
providerName?: string;
|
|
101
103
|
providerUrl?: string;
|
|
102
104
|
title?: string;
|
|
105
|
+
typeOfEmbed?: string;
|
|
103
106
|
url?: string;
|
|
107
|
+
width?: string;
|
|
104
108
|
};
|
|
105
109
|
};
|
|
106
110
|
position?: Position;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Parent } from 'mdast';
|
|
2
|
+
import type { Plugin } from 'unified';
|
|
3
|
+
/**
|
|
4
|
+
* Transform paragraph-wrapped self-closing JSX components into mdxJsxFlowElement nodes.
|
|
5
|
+
*
|
|
6
|
+
* CommonMark wraps multi-line JSX in paragraphs when the opening tag isn't complete
|
|
7
|
+
* on one line. This plugin detects these structures and unwraps them for components
|
|
8
|
+
* in the SELF_CLOSING_BLOCK_TAGS allowlist.
|
|
9
|
+
*
|
|
10
|
+
* Input structure:
|
|
11
|
+
* ```
|
|
12
|
+
* paragraph > html: "<Embed\n typeOfEmbed=\"youtube\"\n/>"
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Output structure:
|
|
16
|
+
* ```
|
|
17
|
+
* mdxJsxFlowElement: { name: "Embed", attributes: [...], children: [] }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
declare const mdxishSelfClosingBlocks: Plugin<[], Parent>;
|
|
21
|
+
export default mdxishSelfClosingBlocks;
|
package/enums.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export enum NodeTypes {
|
|
2
|
+
anchor = 'readme-anchor',
|
|
3
|
+
callout = 'rdme-callout',
|
|
4
|
+
codeTabs = 'code-tabs',
|
|
5
|
+
embedBlock = 'embed-block',
|
|
6
|
+
emoji = 'gemoji',
|
|
7
|
+
figcaption = 'figcaption',
|
|
8
|
+
figure = 'figure',
|
|
9
|
+
glossary = 'readme-glossary-item',
|
|
10
|
+
htmlBlock = 'html-block',
|
|
11
|
+
i = 'i',
|
|
12
|
+
imageBlock = 'image-block',
|
|
13
|
+
plain = 'plain',
|
|
14
|
+
recipe = 'recipe',
|
|
15
|
+
reusableContent = 'reusable-content',
|
|
16
|
+
tableau = 'tableau',
|
|
17
|
+
/** @deprecated Deprecated in favor of `recipe`. */
|
|
18
|
+
tutorialTile = 'tutorial-tile',
|
|
19
|
+
variable = 'readme-variable',
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
"name": "@readme/markdown",
|
|
3
3
|
"description": "ReadMe's React-based Markdown parser",
|
|
4
4
|
"author": "Rafe Goldberg <rafe@readme.io>",
|
|
5
|
-
"version": "13.7.
|
|
5
|
+
"version": "13.7.1",
|
|
6
6
|
"main": "dist/main.node.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"browser": "dist/main.js",
|
|
9
9
|
"files": [
|
|
10
10
|
"styles",
|
|
11
11
|
"components",
|
|
12
|
-
"dist"
|
|
12
|
+
"dist",
|
|
13
|
+
"types.d.ts",
|
|
14
|
+
"enums.ts"
|
|
13
15
|
],
|
|
14
16
|
"scripts": {
|
|
15
17
|
"build": "webpack --mode production && npm run build-types",
|
|
@@ -108,18 +110,18 @@
|
|
|
108
110
|
"@readme/markdown-legacy": "npm:@readme/markdown@^6.87.1",
|
|
109
111
|
"@semantic-release/changelog": "^6.0.3",
|
|
110
112
|
"@semantic-release/git": "^10.0.1",
|
|
111
|
-
"@testing-library/jest-dom": "^6.
|
|
113
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
112
114
|
"@testing-library/react": "^14",
|
|
113
115
|
"@testing-library/user-event": "^14.5.2",
|
|
114
116
|
"@types/hast": "^3.0.4",
|
|
115
|
-
"@types/jest": "^
|
|
117
|
+
"@types/jest": "^30.0.0",
|
|
116
118
|
"@types/mdast": "^4.0.3",
|
|
117
119
|
"@types/mdx": "^2.0.12",
|
|
118
120
|
"@types/unist": "^3.0.2",
|
|
119
121
|
"@vitejs/plugin-react": "^4.2.1",
|
|
120
122
|
"@vitest/coverage-v8": "^4.0.8",
|
|
121
123
|
"@vitest/ui": "^4.0.8",
|
|
122
|
-
"babel-jest": "^
|
|
124
|
+
"babel-jest": "^30.3.0",
|
|
123
125
|
"babel-loader": "^9.1.2",
|
|
124
126
|
"browserify-fs": "^1.0.0",
|
|
125
127
|
"codemirror": "^5.54.0",
|
|
@@ -128,11 +130,11 @@
|
|
|
128
130
|
"eslint": "^8.37.0",
|
|
129
131
|
"hast-util-to-text": "^4.0.2",
|
|
130
132
|
"identity-obj-proxy": "^3.0.0",
|
|
131
|
-
"jest": "^
|
|
132
|
-
"jest-environment-jsdom": "^
|
|
133
|
-
"jest-environment-puppeteer": "^
|
|
134
|
-
"jest-image-snapshot": "^6.
|
|
135
|
-
"jest-puppeteer": "^
|
|
133
|
+
"jest": "^30.3.0",
|
|
134
|
+
"jest-environment-jsdom": "^30.3.0",
|
|
135
|
+
"jest-environment-puppeteer": "^11.0.0",
|
|
136
|
+
"jest-image-snapshot": "^6.5.2",
|
|
137
|
+
"jest-puppeteer": "^11.0.0",
|
|
136
138
|
"mermaid": "^11.12.0",
|
|
137
139
|
"mini-css-extract-plugin": "^2.7.5",
|
|
138
140
|
"prettier": "^3.2.5",
|
|
@@ -167,7 +169,7 @@
|
|
|
167
169
|
},
|
|
168
170
|
{
|
|
169
171
|
"path": "dist/main.node.js",
|
|
170
|
-
"maxSize": "
|
|
172
|
+
"maxSize": "853KB"
|
|
171
173
|
}
|
|
172
174
|
]
|
|
173
175
|
},
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import type { NodeTypes } from './enums';
|
|
2
|
+
import type { Element } from 'hast';
|
|
3
|
+
import type {
|
|
4
|
+
Code,
|
|
5
|
+
Data,
|
|
6
|
+
Literal,
|
|
7
|
+
Parent,
|
|
8
|
+
Blockquote,
|
|
9
|
+
Node,
|
|
10
|
+
PhrasingContent,
|
|
11
|
+
Root,
|
|
12
|
+
Text,
|
|
13
|
+
Table,
|
|
14
|
+
BlockContent,
|
|
15
|
+
Link,
|
|
16
|
+
RootContent,
|
|
17
|
+
} from 'mdast';
|
|
18
|
+
import type { MdxJsxFlowElementHast } from 'mdast-util-mdx-jsx';
|
|
19
|
+
import type { MDXModule } from 'mdx/types';
|
|
20
|
+
import type { Position } from 'unist';
|
|
21
|
+
|
|
22
|
+
export type Callout = Omit<Blockquote, 'children' | 'type'> & {
|
|
23
|
+
children: BlockContent[];
|
|
24
|
+
data: Data & {
|
|
25
|
+
hName: 'Callout' | 'rdme-callout';
|
|
26
|
+
hProperties: {
|
|
27
|
+
empty?: boolean;
|
|
28
|
+
icon: string;
|
|
29
|
+
theme: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
type: NodeTypes.callout;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export interface CodeTabs extends Parent {
|
|
36
|
+
children: Code[];
|
|
37
|
+
data?: Data & {
|
|
38
|
+
hName: 'CodeTabs';
|
|
39
|
+
};
|
|
40
|
+
type: NodeTypes.codeTabs;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface Embed extends Link {
|
|
44
|
+
title: '@embed';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface EmbedBlock extends Node {
|
|
48
|
+
data: Data & {
|
|
49
|
+
hName: 'Embed' | 'embed';
|
|
50
|
+
hProperties: Record<string, unknown> & {
|
|
51
|
+
favicon?: string;
|
|
52
|
+
height?:string;
|
|
53
|
+
href?: string;
|
|
54
|
+
html?: string;
|
|
55
|
+
iframe?: boolean;
|
|
56
|
+
image?: string;
|
|
57
|
+
provider?:string;
|
|
58
|
+
providerName?: string;
|
|
59
|
+
providerUrl?: string;
|
|
60
|
+
title: string;
|
|
61
|
+
typeOfEmbed?: string;
|
|
62
|
+
url: string;
|
|
63
|
+
width?: string;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
label?: string;
|
|
67
|
+
title?: string;
|
|
68
|
+
type: NodeTypes.embedBlock;
|
|
69
|
+
url?: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface Figure extends Node {
|
|
73
|
+
children: [ImageBlock & { url: string }, FigCaption];
|
|
74
|
+
data: {
|
|
75
|
+
hName: 'figure';
|
|
76
|
+
};
|
|
77
|
+
type: NodeTypes.figure;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface FigCaption extends Node {
|
|
81
|
+
children: BlockContent[];
|
|
82
|
+
data: {
|
|
83
|
+
hName: 'figcaption';
|
|
84
|
+
};
|
|
85
|
+
type: NodeTypes.figcaption;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface HTMLBlock extends Node {
|
|
89
|
+
children: Text[];
|
|
90
|
+
data: Data & {
|
|
91
|
+
hName: 'html-block';
|
|
92
|
+
hProperties: {
|
|
93
|
+
html: string;
|
|
94
|
+
runScripts?: boolean | string;
|
|
95
|
+
safeMode?: string;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
type: NodeTypes.htmlBlock;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface Plain extends Literal {
|
|
102
|
+
type: NodeTypes.plain;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export type ImageAlign = 'center' | 'left' | 'right';
|
|
106
|
+
|
|
107
|
+
export interface ImageBlockAttrs {
|
|
108
|
+
align?: ImageAlign;
|
|
109
|
+
alt: string;
|
|
110
|
+
border?: boolean;
|
|
111
|
+
caption?: string;
|
|
112
|
+
children?: RootContent[];
|
|
113
|
+
className?: string;
|
|
114
|
+
height?: string;
|
|
115
|
+
lazy?: boolean;
|
|
116
|
+
sizing?: string;
|
|
117
|
+
src: string;
|
|
118
|
+
title: string;
|
|
119
|
+
width?: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface ImageBlock extends ImageBlockAttrs, Omit<Parent, 'children'> {
|
|
123
|
+
data: Data & {
|
|
124
|
+
hName: 'img';
|
|
125
|
+
hProperties: ImageBlockAttrs;
|
|
126
|
+
};
|
|
127
|
+
type: NodeTypes.imageBlock;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface Gemoji extends Node {
|
|
131
|
+
name: string;
|
|
132
|
+
type: NodeTypes.emoji;
|
|
133
|
+
value?: string;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface FaEmoji extends Literal {
|
|
137
|
+
type: NodeTypes.i;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface Tableau extends Omit<Table, 'type'> {
|
|
141
|
+
type: NodeTypes.tableau;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface Recipe extends Node {
|
|
145
|
+
backgroundColor: string;
|
|
146
|
+
emoji: string;
|
|
147
|
+
id: string;
|
|
148
|
+
link: string;
|
|
149
|
+
slug: string;
|
|
150
|
+
title: string;
|
|
151
|
+
// Keeping both types for backwards compatibility
|
|
152
|
+
type: NodeTypes.recipe | NodeTypes.tutorialTile;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export interface ReusableContent extends Parent {
|
|
156
|
+
children: RootContent[];
|
|
157
|
+
tag: string;
|
|
158
|
+
type: NodeTypes.reusableContent;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface Variable extends Node {
|
|
162
|
+
data: Data & {
|
|
163
|
+
hName: 'readme-variable' | 'Variable';
|
|
164
|
+
hProperties: {
|
|
165
|
+
name: string;
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
value: string;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export interface Glossary extends Node {
|
|
172
|
+
children: [{ type: 'text'; value: string }];
|
|
173
|
+
data: Data & {
|
|
174
|
+
hName: 'Glossary';
|
|
175
|
+
hProperties: { term: string };
|
|
176
|
+
};
|
|
177
|
+
position?: Position;
|
|
178
|
+
type: NodeTypes.glossary;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export interface Anchor extends Node {
|
|
182
|
+
children: PhrasingContent[];
|
|
183
|
+
data: Data & {
|
|
184
|
+
hName: 'Anchor';
|
|
185
|
+
hProperties: {
|
|
186
|
+
href: string;
|
|
187
|
+
label?: string;
|
|
188
|
+
target?: string;
|
|
189
|
+
title?: string;
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
position?: Position;
|
|
193
|
+
type: NodeTypes.anchor;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
declare module 'mdast' {
|
|
197
|
+
interface BlockContentMap {
|
|
198
|
+
[NodeTypes.callout]: Callout;
|
|
199
|
+
[NodeTypes.codeTabs]: CodeTabs;
|
|
200
|
+
[NodeTypes.embedBlock]: EmbedBlock;
|
|
201
|
+
[NodeTypes.figure]: Figure;
|
|
202
|
+
[NodeTypes.htmlBlock]: HTMLBlock;
|
|
203
|
+
[NodeTypes.imageBlock]: ImageBlock;
|
|
204
|
+
[NodeTypes.plain]: Plain;
|
|
205
|
+
[NodeTypes.recipe]: Recipe;
|
|
206
|
+
[NodeTypes.reusableContent]: ReusableContent;
|
|
207
|
+
[NodeTypes.tableau]: Tableau;
|
|
208
|
+
[NodeTypes.tutorialTile]: Recipe;
|
|
209
|
+
link: Embed | Link;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
interface PhrasingContentMap {
|
|
213
|
+
[NodeTypes.anchor]: Anchor;
|
|
214
|
+
[NodeTypes.emoji]: Gemoji;
|
|
215
|
+
[NodeTypes.i]: FaEmoji;
|
|
216
|
+
[NodeTypes.glossary]: Glossary;
|
|
217
|
+
[NodeTypes.variable]: Variable;
|
|
218
|
+
[NodeTypes.plain]: Plain;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
interface RootContentMap {
|
|
222
|
+
Link: Embed | Link;
|
|
223
|
+
[NodeTypes.anchor]: Anchor;
|
|
224
|
+
[NodeTypes.callout]: Callout;
|
|
225
|
+
[NodeTypes.codeTabs]: CodeTabs;
|
|
226
|
+
[NodeTypes.embedBlock]: EmbedBlock;
|
|
227
|
+
[NodeTypes.emoji]: Gemoji;
|
|
228
|
+
[NodeTypes.figure]: Figure;
|
|
229
|
+
[NodeTypes.glossary]: Glossary;
|
|
230
|
+
[NodeTypes.htmlBlock]: HTMLBlock;
|
|
231
|
+
[NodeTypes.i]: FaEmoji;
|
|
232
|
+
[NodeTypes.imageBlock]: ImageBlock;
|
|
233
|
+
[NodeTypes.plain]: Plain;
|
|
234
|
+
[NodeTypes.recipe]: Recipe;
|
|
235
|
+
[NodeTypes.reusableContent]: ReusableContent;
|
|
236
|
+
[NodeTypes.tableau]: Tableau;
|
|
237
|
+
[NodeTypes.tutorialTile]: Recipe;
|
|
238
|
+
[NodeTypes.variable]: Variable;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
interface HastHeading extends Element {
|
|
243
|
+
depth: number;
|
|
244
|
+
tagName: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
interface TocList extends Element {
|
|
248
|
+
children: TocListItem[];
|
|
249
|
+
tagName: 'ul';
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
interface Variables {
|
|
253
|
+
defaults: { default: string; name: string }[];
|
|
254
|
+
user: Record<string, string>;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
interface TocListItem extends Element {
|
|
258
|
+
children: (TocEntry | TocList)[];
|
|
259
|
+
tagName: 'li';
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
interface TocEntry extends Element {
|
|
263
|
+
children: (Element | Literal)[];
|
|
264
|
+
tagName: 'a';
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
type IndexableElements = HastHeading | MdxJsxFlowElementHast;
|
|
268
|
+
|
|
269
|
+
interface RMDXModule extends MDXModule {
|
|
270
|
+
Toc: React.FC<Record<string, unknown>> | null;
|
|
271
|
+
toc: IndexableElements[];
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
interface CustomComponents extends Record<string, RMDXModule> {}
|
|
275
|
+
|
|
276
|
+
interface MdastComponents extends Record<string, Root> {}
|
|
277
|
+
|
|
278
|
+
declare module '*.md' {
|
|
279
|
+
const content: string;
|
|
280
|
+
export default content;
|
|
281
|
+
}
|