markdown-to-jsx 8.0.0 → 9.0.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.
@@ -0,0 +1,356 @@
1
+ import * as React from "react";
2
+ /**
3
+ * Analogous to `node.type`. Please note that the values here may change at any time,
4
+ * so do not hard code against the value directly.
5
+ */
6
+ declare const RuleTypeConst: {
7
+ readonly blockQuote: 0;
8
+ readonly breakLine: 1;
9
+ readonly breakThematic: 2;
10
+ readonly codeBlock: 3;
11
+ readonly codeInline: 4;
12
+ readonly footnote: 5;
13
+ readonly footnoteReference: 6;
14
+ readonly frontmatter: 7;
15
+ readonly gfmTask: 8;
16
+ readonly heading: 9;
17
+ readonly htmlBlock: 10;
18
+ readonly htmlComment: 11;
19
+ readonly htmlSelfClosing: 12;
20
+ readonly image: 13;
21
+ readonly link: 14;
22
+ readonly orderedList: 15;
23
+ readonly paragraph: 16;
24
+ readonly ref: 17;
25
+ readonly refCollection: 18;
26
+ readonly table: 19;
27
+ readonly text: 20;
28
+ readonly textFormatted: 21;
29
+ readonly unorderedList: 22;
30
+ };
31
+ type RuleTypeValue = (typeof RuleTypeConst)[keyof typeof RuleTypeConst];
32
+ /**
33
+ * markdown-to-jsx types and interfaces
34
+ */
35
+ declare namespace MarkdownToJSX {
36
+ /**
37
+ * RequireAtLeastOne<{ ... }> <- only requires at least one key
38
+ */
39
+ type RequireAtLeastOne<
40
+ T,
41
+ Keys extends keyof T = keyof T
42
+ > = Pick<T, Exclude<keyof T, Keys>> & { [K in Keys]-? : Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>> }[Keys];
43
+ type CreateElement = typeof React.createElement;
44
+ type HTMLTags = keyof React.JSX.IntrinsicElements & (string & {});
45
+ type State = {
46
+ /** true if the current content is inside anchor link grammar */
47
+ inAnchor?: boolean;
48
+ /** true if inside a blockquote */
49
+ inBlockQuote?: boolean;
50
+ /** true if parsing in an HTML context */
51
+ inHTML?: boolean;
52
+ /** true if in a list */
53
+ inList?: boolean;
54
+ /** true if parsing in an inline context (subset of rules around formatting and links) */
55
+ inline?: boolean;
56
+ /** use this for the `key` prop */
57
+ key?: React.Key;
58
+ /** reference definitions (footnotes are stored with '^' prefix) */
59
+ refs?: {
60
+ [key: string]: {
61
+ target: string;
62
+ title: string | undefined;
63
+ };
64
+ };
65
+ /** current recursion depth during rendering */
66
+ renderDepth?: number;
67
+ };
68
+ interface BlockQuoteNode {
69
+ alert?: string;
70
+ children: MarkdownToJSX.ASTNode[];
71
+ type: typeof RuleType2.blockQuote;
72
+ }
73
+ interface BreakLineNode {
74
+ type: typeof RuleType2.breakLine;
75
+ }
76
+ interface BreakThematicNode {
77
+ type: typeof RuleType2.breakThematic;
78
+ }
79
+ interface CodeBlockNode {
80
+ type: typeof RuleType2.codeBlock;
81
+ attrs?: React.JSX.IntrinsicAttributes;
82
+ lang?: string;
83
+ text: string;
84
+ }
85
+ interface CodeInlineNode {
86
+ type: typeof RuleType2.codeInline;
87
+ text: string;
88
+ }
89
+ interface FootnoteNode {
90
+ type: typeof RuleType2.footnote;
91
+ }
92
+ interface FootnoteReferenceNode {
93
+ type: typeof RuleType2.footnoteReference;
94
+ target: string;
95
+ text: string;
96
+ }
97
+ interface FrontmatterNode {
98
+ type: typeof RuleType2.frontmatter;
99
+ text: string;
100
+ }
101
+ interface GFMTaskNode {
102
+ type: typeof RuleType2.gfmTask;
103
+ completed: boolean;
104
+ }
105
+ interface HeadingNode {
106
+ type: typeof RuleType2.heading;
107
+ children: MarkdownToJSX.ASTNode[];
108
+ id: string;
109
+ level: 1 | 2 | 3 | 4 | 5 | 6;
110
+ }
111
+ interface HTMLCommentNode {
112
+ type: typeof RuleType2.htmlComment;
113
+ text: string;
114
+ }
115
+ interface ImageNode {
116
+ type: typeof RuleType2.image;
117
+ alt?: string;
118
+ target: string;
119
+ title?: string;
120
+ }
121
+ interface LinkNode {
122
+ type: typeof RuleType2.link;
123
+ children: MarkdownToJSX.ASTNode[];
124
+ target: string | null;
125
+ title?: string;
126
+ }
127
+ interface OrderedListNode {
128
+ type: typeof RuleType2.orderedList;
129
+ items: MarkdownToJSX.ASTNode[][];
130
+ start?: number;
131
+ }
132
+ interface UnorderedListNode {
133
+ type: typeof RuleType2.unorderedList;
134
+ items: MarkdownToJSX.ASTNode[][];
135
+ }
136
+ interface ParagraphNode {
137
+ type: typeof RuleType2.paragraph;
138
+ children: MarkdownToJSX.ASTNode[];
139
+ }
140
+ interface ReferenceNode {
141
+ type: typeof RuleType2.ref;
142
+ }
143
+ interface ReferenceCollectionNode {
144
+ type: typeof RuleType2.refCollection;
145
+ refs: {
146
+ [key: string]: {
147
+ target: string;
148
+ title: string | undefined;
149
+ };
150
+ };
151
+ }
152
+ interface TableNode {
153
+ type: typeof RuleType2.table;
154
+ /**
155
+ * alignment for each table column
156
+ */
157
+ align: ("left" | "right" | "center")[];
158
+ cells: MarkdownToJSX.ASTNode[][][];
159
+ header: MarkdownToJSX.ASTNode[][];
160
+ }
161
+ interface TextNode {
162
+ type: typeof RuleType2.text;
163
+ text: string;
164
+ }
165
+ interface FormattedTextNode {
166
+ type: typeof RuleType2.textFormatted;
167
+ /**
168
+ * the corresponding html tag
169
+ */
170
+ tag: string;
171
+ children: MarkdownToJSX.ASTNode[];
172
+ }
173
+ interface HTMLNode {
174
+ type: typeof RuleType2.htmlBlock;
175
+ attrs?: Record<string, any>;
176
+ children?: ASTNode[] | undefined;
177
+ noInnerParse?: Boolean;
178
+ tag: string;
179
+ text?: string | undefined;
180
+ }
181
+ interface HTMLSelfClosingNode {
182
+ type: typeof RuleType2.htmlSelfClosing;
183
+ attrs?: Record<string, any>;
184
+ isClosingTag?: boolean;
185
+ tag: string;
186
+ }
187
+ type ASTNode = BlockQuoteNode | BreakLineNode | BreakThematicNode | CodeBlockNode | CodeInlineNode | FootnoteNode | FootnoteReferenceNode | FrontmatterNode | GFMTaskNode | HeadingNode | HTMLCommentNode | ImageNode | LinkNode | OrderedListNode | UnorderedListNode | ParagraphNode | ReferenceNode | ReferenceCollectionNode | TableNode | TextNode | FormattedTextNode | HTMLNode | HTMLSelfClosingNode;
188
+ type ASTRender = (ast: MarkdownToJSX.ASTNode | MarkdownToJSX.ASTNode[], state: MarkdownToJSX.State) => React.ReactNode;
189
+ type Override = RequireAtLeastOne<{
190
+ component: React.ElementType;
191
+ props: Object;
192
+ }> | React.ElementType;
193
+ type Overrides = { [tag in HTMLTags]? : Override } & {
194
+ [customComponent: string]: Override;
195
+ };
196
+ type Options = Partial<{
197
+ /**
198
+ * Ultimate control over the output of all rendered JSX.
199
+ */
200
+ createElement: (tag: Parameters<CreateElement>[0], props: React.JSX.IntrinsicAttributes, ...children: React.ReactNode[]) => React.ReactNode;
201
+ /**
202
+ * The library automatically generates an anchor tag for bare URLs included in the markdown
203
+ * document, but this behavior can be disabled if desired.
204
+ */
205
+ disableAutoLink: boolean;
206
+ /**
207
+ * Disable the compiler's best-effort transcription of provided raw HTML
208
+ * into JSX-equivalent. This is the functionality that prevents the need to
209
+ * use `dangerouslySetInnerHTML` in React.
210
+ */
211
+ disableParsingRawHTML: boolean;
212
+ /**
213
+ * Enable GFM tagfilter extension to filter potentially dangerous HTML tags.
214
+ * When enabled, the following tags are escaped: title, textarea, style, xmp,
215
+ * iframe, noembed, noframes, script, plaintext.
216
+ * https://github.github.com/gfm/#disallowed-raw-html-extension-
217
+ * @default true
218
+ */
219
+ tagfilter?: boolean;
220
+ /**
221
+ * Forces the compiler to have space between hash sign and the header text which
222
+ * is explicitly stated in the most of the markdown specs.
223
+ * https://github.github.com/gfm/#atx-heading
224
+ * `The opening sequence of # characters must be followed by a space or by the end of line.`
225
+ */
226
+ enforceAtxHeadings: boolean;
227
+ /**
228
+ * Forces the compiler to always output content with a block-level wrapper
229
+ * (`<p>` or any block-level syntax your markdown already contains.)
230
+ */
231
+ forceBlock: boolean;
232
+ /**
233
+ * Forces the compiler to always output content with an inline wrapper (`<span>`)
234
+ */
235
+ forceInline: boolean;
236
+ /**
237
+ * Forces the compiler to wrap results, even if there is only a single
238
+ * child or no children.
239
+ */
240
+ forceWrapper: boolean;
241
+ /**
242
+ * Selectively control the output of particular HTML tags as they would be
243
+ * emitted by the compiler.
244
+ */
245
+ overrides: Overrides;
246
+ /**
247
+ * Allows for full control over rendering of particular rules.
248
+ * For example, to implement a LaTeX renderer such as `react-katex`:
249
+ *
250
+ * ```
251
+ * renderRule(next, node, renderChildren, state) {
252
+ * if (node.type === RuleType.codeBlock && node.lang === 'latex') {
253
+ * return (
254
+ * <TeX as="div" key={state.key}>
255
+ * {String.raw`${node.text}`}
256
+ * </TeX>
257
+ * )
258
+ * }
259
+ *
260
+ * return next();
261
+ * }
262
+ * ```
263
+ *
264
+ * Thar be dragons obviously, but you can do a lot with this
265
+ * (have fun!) To see how things work internally, check the `render`
266
+ * method in source for a particular rule.
267
+ */
268
+ renderRule: (next: () => React.ReactNode, node: ASTNode, renderChildren: ASTRender, state: State) => React.ReactNode;
269
+ /**
270
+ * Override the built-in sanitizer function for URLs, etc if desired. The built-in version is available as a library
271
+ called `sanitizer`.
272
+ */
273
+ sanitizer: (value: string, tag: HTMLTags, attribute: string) => string | null;
274
+ /**
275
+ * Override normalization of non-URI-safe characters for use in generating
276
+ * HTML IDs for anchor linking purposes.
277
+ */
278
+ slugify: (input: string, defaultFn: (input: string) => string) => string;
279
+ /**
280
+ * Declare the type of the wrapper to be used when there are multiple
281
+ * children to render. Set to `null` to get an array of children back
282
+ * without any wrapper, or use `React.Fragment` to get a React element
283
+ * that won't show up in the DOM.
284
+ */
285
+ wrapper: React.ElementType | null;
286
+ /**
287
+ * Props to apply to the wrapper element.
288
+ */
289
+ wrapperProps?: React.JSX.IntrinsicAttributes;
290
+ }>;
291
+ {}
292
+ ;
293
+ }
294
+ declare const RuleType2: typeof RuleTypeConst;
295
+ type RuleType2 = RuleTypeValue;
296
+ declare global {
297
+ var parseMetrics: {
298
+ blockParsers: {
299
+ [key: string]: {
300
+ attempts: number;
301
+ hits: number;
302
+ hitTimings: number[];
303
+ };
304
+ };
305
+ inlineParsers: {
306
+ [key: string]: {
307
+ attempts: number;
308
+ hits: number;
309
+ hitTimings: number[];
310
+ };
311
+ };
312
+ totalOperations: number;
313
+ blockParseIterations: number;
314
+ inlineParseIterations: number;
315
+ } | null;
316
+ var parseMetricsStartTimes: Map<string, number> | null;
317
+ }
318
+ /**
319
+ * Given a markdown string, return an abstract syntax tree (AST) of the markdown.
320
+ *
321
+ * The first node in the AST is a reference collection node. This node contains all the
322
+ * reference definitions found in the markdown. These reference definitions are used to
323
+ * resolve reference links and images in the markdown.
324
+ *
325
+ * @param source - The markdown string to parse.
326
+ * @param options - The options for the parser.
327
+ * @returns The AST of the markdown.
328
+ */
329
+ declare function parser(source: string, options?: MarkdownToJSX.Options): MarkdownToJSX.ASTNode[];
330
+ declare function sanitizer(input: string): string | null;
331
+ declare function slugify(str: string): string;
332
+ type HTMLOverride = {
333
+ component?: string;
334
+ props?: Record<string, string | number | boolean>;
335
+ } | string;
336
+ type HTMLOverrides = { [tag in MarkdownToJSX.HTMLTags]? : HTMLOverride } & {
337
+ [customComponent: string]: HTMLOverride;
338
+ };
339
+ type HTMLOptions = Omit<MarkdownToJSX.Options, "createElement" | "wrapperProps" | "overrides"> & {
340
+ refs?: {
341
+ [key: string]: {
342
+ target: string;
343
+ title: string | undefined;
344
+ };
345
+ };
346
+ renderRule?: (next: () => string, node: MarkdownToJSX.ASTNode, renderChildren: (children: MarkdownToJSX.ASTNode[]) => string, state: MarkdownToJSX.State) => string;
347
+ overrides?: HTMLOverrides;
348
+ wrapperProps?: Record<string, string | number | boolean>;
349
+ };
350
+ declare function astToHTML(nodes: MarkdownToJSX.ASTNode[], options?: HTMLOptions): string;
351
+ /**
352
+ * Compiler function that parses markdown and renders to HTML string
353
+ * Convenience function that combines parser() and html()
354
+ */
355
+ declare function compiler(markdown: string, options?: HTMLOptions): string;
356
+ export { slugify, sanitizer, parser, compiler, astToHTML, RuleType2 as RuleType, MarkdownToJSX, HTMLOverrides, HTMLOverride, HTMLOptions };
package/dist/html.d.ts ADDED
@@ -0,0 +1,356 @@
1
+ import * as React from "react";
2
+ /**
3
+ * Analogous to `node.type`. Please note that the values here may change at any time,
4
+ * so do not hard code against the value directly.
5
+ */
6
+ declare const RuleTypeConst: {
7
+ readonly blockQuote: 0;
8
+ readonly breakLine: 1;
9
+ readonly breakThematic: 2;
10
+ readonly codeBlock: 3;
11
+ readonly codeInline: 4;
12
+ readonly footnote: 5;
13
+ readonly footnoteReference: 6;
14
+ readonly frontmatter: 7;
15
+ readonly gfmTask: 8;
16
+ readonly heading: 9;
17
+ readonly htmlBlock: 10;
18
+ readonly htmlComment: 11;
19
+ readonly htmlSelfClosing: 12;
20
+ readonly image: 13;
21
+ readonly link: 14;
22
+ readonly orderedList: 15;
23
+ readonly paragraph: 16;
24
+ readonly ref: 17;
25
+ readonly refCollection: 18;
26
+ readonly table: 19;
27
+ readonly text: 20;
28
+ readonly textFormatted: 21;
29
+ readonly unorderedList: 22;
30
+ };
31
+ type RuleTypeValue = (typeof RuleTypeConst)[keyof typeof RuleTypeConst];
32
+ /**
33
+ * markdown-to-jsx types and interfaces
34
+ */
35
+ declare namespace MarkdownToJSX {
36
+ /**
37
+ * RequireAtLeastOne<{ ... }> <- only requires at least one key
38
+ */
39
+ type RequireAtLeastOne<
40
+ T,
41
+ Keys extends keyof T = keyof T
42
+ > = Pick<T, Exclude<keyof T, Keys>> & { [K in Keys]-? : Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>> }[Keys];
43
+ type CreateElement = typeof React.createElement;
44
+ type HTMLTags = keyof React.JSX.IntrinsicElements & (string & {});
45
+ type State = {
46
+ /** true if the current content is inside anchor link grammar */
47
+ inAnchor?: boolean;
48
+ /** true if inside a blockquote */
49
+ inBlockQuote?: boolean;
50
+ /** true if parsing in an HTML context */
51
+ inHTML?: boolean;
52
+ /** true if in a list */
53
+ inList?: boolean;
54
+ /** true if parsing in an inline context (subset of rules around formatting and links) */
55
+ inline?: boolean;
56
+ /** use this for the `key` prop */
57
+ key?: React.Key;
58
+ /** reference definitions (footnotes are stored with '^' prefix) */
59
+ refs?: {
60
+ [key: string]: {
61
+ target: string;
62
+ title: string | undefined;
63
+ };
64
+ };
65
+ /** current recursion depth during rendering */
66
+ renderDepth?: number;
67
+ };
68
+ interface BlockQuoteNode {
69
+ alert?: string;
70
+ children: MarkdownToJSX.ASTNode[];
71
+ type: typeof RuleType2.blockQuote;
72
+ }
73
+ interface BreakLineNode {
74
+ type: typeof RuleType2.breakLine;
75
+ }
76
+ interface BreakThematicNode {
77
+ type: typeof RuleType2.breakThematic;
78
+ }
79
+ interface CodeBlockNode {
80
+ type: typeof RuleType2.codeBlock;
81
+ attrs?: React.JSX.IntrinsicAttributes;
82
+ lang?: string;
83
+ text: string;
84
+ }
85
+ interface CodeInlineNode {
86
+ type: typeof RuleType2.codeInline;
87
+ text: string;
88
+ }
89
+ interface FootnoteNode {
90
+ type: typeof RuleType2.footnote;
91
+ }
92
+ interface FootnoteReferenceNode {
93
+ type: typeof RuleType2.footnoteReference;
94
+ target: string;
95
+ text: string;
96
+ }
97
+ interface FrontmatterNode {
98
+ type: typeof RuleType2.frontmatter;
99
+ text: string;
100
+ }
101
+ interface GFMTaskNode {
102
+ type: typeof RuleType2.gfmTask;
103
+ completed: boolean;
104
+ }
105
+ interface HeadingNode {
106
+ type: typeof RuleType2.heading;
107
+ children: MarkdownToJSX.ASTNode[];
108
+ id: string;
109
+ level: 1 | 2 | 3 | 4 | 5 | 6;
110
+ }
111
+ interface HTMLCommentNode {
112
+ type: typeof RuleType2.htmlComment;
113
+ text: string;
114
+ }
115
+ interface ImageNode {
116
+ type: typeof RuleType2.image;
117
+ alt?: string;
118
+ target: string;
119
+ title?: string;
120
+ }
121
+ interface LinkNode {
122
+ type: typeof RuleType2.link;
123
+ children: MarkdownToJSX.ASTNode[];
124
+ target: string | null;
125
+ title?: string;
126
+ }
127
+ interface OrderedListNode {
128
+ type: typeof RuleType2.orderedList;
129
+ items: MarkdownToJSX.ASTNode[][];
130
+ start?: number;
131
+ }
132
+ interface UnorderedListNode {
133
+ type: typeof RuleType2.unorderedList;
134
+ items: MarkdownToJSX.ASTNode[][];
135
+ }
136
+ interface ParagraphNode {
137
+ type: typeof RuleType2.paragraph;
138
+ children: MarkdownToJSX.ASTNode[];
139
+ }
140
+ interface ReferenceNode {
141
+ type: typeof RuleType2.ref;
142
+ }
143
+ interface ReferenceCollectionNode {
144
+ type: typeof RuleType2.refCollection;
145
+ refs: {
146
+ [key: string]: {
147
+ target: string;
148
+ title: string | undefined;
149
+ };
150
+ };
151
+ }
152
+ interface TableNode {
153
+ type: typeof RuleType2.table;
154
+ /**
155
+ * alignment for each table column
156
+ */
157
+ align: ("left" | "right" | "center")[];
158
+ cells: MarkdownToJSX.ASTNode[][][];
159
+ header: MarkdownToJSX.ASTNode[][];
160
+ }
161
+ interface TextNode {
162
+ type: typeof RuleType2.text;
163
+ text: string;
164
+ }
165
+ interface FormattedTextNode {
166
+ type: typeof RuleType2.textFormatted;
167
+ /**
168
+ * the corresponding html tag
169
+ */
170
+ tag: string;
171
+ children: MarkdownToJSX.ASTNode[];
172
+ }
173
+ interface HTMLNode {
174
+ type: typeof RuleType2.htmlBlock;
175
+ attrs?: Record<string, any>;
176
+ children?: ASTNode[] | undefined;
177
+ noInnerParse?: Boolean;
178
+ tag: string;
179
+ text?: string | undefined;
180
+ }
181
+ interface HTMLSelfClosingNode {
182
+ type: typeof RuleType2.htmlSelfClosing;
183
+ attrs?: Record<string, any>;
184
+ isClosingTag?: boolean;
185
+ tag: string;
186
+ }
187
+ type ASTNode = BlockQuoteNode | BreakLineNode | BreakThematicNode | CodeBlockNode | CodeInlineNode | FootnoteNode | FootnoteReferenceNode | FrontmatterNode | GFMTaskNode | HeadingNode | HTMLCommentNode | ImageNode | LinkNode | OrderedListNode | UnorderedListNode | ParagraphNode | ReferenceNode | ReferenceCollectionNode | TableNode | TextNode | FormattedTextNode | HTMLNode | HTMLSelfClosingNode;
188
+ type ASTRender = (ast: MarkdownToJSX.ASTNode | MarkdownToJSX.ASTNode[], state: MarkdownToJSX.State) => React.ReactNode;
189
+ type Override = RequireAtLeastOne<{
190
+ component: React.ElementType;
191
+ props: Object;
192
+ }> | React.ElementType;
193
+ type Overrides = { [tag in HTMLTags]? : Override } & {
194
+ [customComponent: string]: Override;
195
+ };
196
+ type Options = Partial<{
197
+ /**
198
+ * Ultimate control over the output of all rendered JSX.
199
+ */
200
+ createElement: (tag: Parameters<CreateElement>[0], props: React.JSX.IntrinsicAttributes, ...children: React.ReactNode[]) => React.ReactNode;
201
+ /**
202
+ * The library automatically generates an anchor tag for bare URLs included in the markdown
203
+ * document, but this behavior can be disabled if desired.
204
+ */
205
+ disableAutoLink: boolean;
206
+ /**
207
+ * Disable the compiler's best-effort transcription of provided raw HTML
208
+ * into JSX-equivalent. This is the functionality that prevents the need to
209
+ * use `dangerouslySetInnerHTML` in React.
210
+ */
211
+ disableParsingRawHTML: boolean;
212
+ /**
213
+ * Enable GFM tagfilter extension to filter potentially dangerous HTML tags.
214
+ * When enabled, the following tags are escaped: title, textarea, style, xmp,
215
+ * iframe, noembed, noframes, script, plaintext.
216
+ * https://github.github.com/gfm/#disallowed-raw-html-extension-
217
+ * @default true
218
+ */
219
+ tagfilter?: boolean;
220
+ /**
221
+ * Forces the compiler to have space between hash sign and the header text which
222
+ * is explicitly stated in the most of the markdown specs.
223
+ * https://github.github.com/gfm/#atx-heading
224
+ * `The opening sequence of # characters must be followed by a space or by the end of line.`
225
+ */
226
+ enforceAtxHeadings: boolean;
227
+ /**
228
+ * Forces the compiler to always output content with a block-level wrapper
229
+ * (`<p>` or any block-level syntax your markdown already contains.)
230
+ */
231
+ forceBlock: boolean;
232
+ /**
233
+ * Forces the compiler to always output content with an inline wrapper (`<span>`)
234
+ */
235
+ forceInline: boolean;
236
+ /**
237
+ * Forces the compiler to wrap results, even if there is only a single
238
+ * child or no children.
239
+ */
240
+ forceWrapper: boolean;
241
+ /**
242
+ * Selectively control the output of particular HTML tags as they would be
243
+ * emitted by the compiler.
244
+ */
245
+ overrides: Overrides;
246
+ /**
247
+ * Allows for full control over rendering of particular rules.
248
+ * For example, to implement a LaTeX renderer such as `react-katex`:
249
+ *
250
+ * ```
251
+ * renderRule(next, node, renderChildren, state) {
252
+ * if (node.type === RuleType.codeBlock && node.lang === 'latex') {
253
+ * return (
254
+ * <TeX as="div" key={state.key}>
255
+ * {String.raw`${node.text}`}
256
+ * </TeX>
257
+ * )
258
+ * }
259
+ *
260
+ * return next();
261
+ * }
262
+ * ```
263
+ *
264
+ * Thar be dragons obviously, but you can do a lot with this
265
+ * (have fun!) To see how things work internally, check the `render`
266
+ * method in source for a particular rule.
267
+ */
268
+ renderRule: (next: () => React.ReactNode, node: ASTNode, renderChildren: ASTRender, state: State) => React.ReactNode;
269
+ /**
270
+ * Override the built-in sanitizer function for URLs, etc if desired. The built-in version is available as a library
271
+ called `sanitizer`.
272
+ */
273
+ sanitizer: (value: string, tag: HTMLTags, attribute: string) => string | null;
274
+ /**
275
+ * Override normalization of non-URI-safe characters for use in generating
276
+ * HTML IDs for anchor linking purposes.
277
+ */
278
+ slugify: (input: string, defaultFn: (input: string) => string) => string;
279
+ /**
280
+ * Declare the type of the wrapper to be used when there are multiple
281
+ * children to render. Set to `null` to get an array of children back
282
+ * without any wrapper, or use `React.Fragment` to get a React element
283
+ * that won't show up in the DOM.
284
+ */
285
+ wrapper: React.ElementType | null;
286
+ /**
287
+ * Props to apply to the wrapper element.
288
+ */
289
+ wrapperProps?: React.JSX.IntrinsicAttributes;
290
+ }>;
291
+ {}
292
+ ;
293
+ }
294
+ declare const RuleType2: typeof RuleTypeConst;
295
+ type RuleType2 = RuleTypeValue;
296
+ declare global {
297
+ var parseMetrics: {
298
+ blockParsers: {
299
+ [key: string]: {
300
+ attempts: number;
301
+ hits: number;
302
+ hitTimings: number[];
303
+ };
304
+ };
305
+ inlineParsers: {
306
+ [key: string]: {
307
+ attempts: number;
308
+ hits: number;
309
+ hitTimings: number[];
310
+ };
311
+ };
312
+ totalOperations: number;
313
+ blockParseIterations: number;
314
+ inlineParseIterations: number;
315
+ } | null;
316
+ var parseMetricsStartTimes: Map<string, number> | null;
317
+ }
318
+ /**
319
+ * Given a markdown string, return an abstract syntax tree (AST) of the markdown.
320
+ *
321
+ * The first node in the AST is a reference collection node. This node contains all the
322
+ * reference definitions found in the markdown. These reference definitions are used to
323
+ * resolve reference links and images in the markdown.
324
+ *
325
+ * @param source - The markdown string to parse.
326
+ * @param options - The options for the parser.
327
+ * @returns The AST of the markdown.
328
+ */
329
+ declare function parser(source: string, options?: MarkdownToJSX.Options): MarkdownToJSX.ASTNode[];
330
+ declare function sanitizer(input: string): string | null;
331
+ declare function slugify(str: string): string;
332
+ type HTMLOverride = {
333
+ component?: string;
334
+ props?: Record<string, string | number | boolean>;
335
+ } | string;
336
+ type HTMLOverrides = { [tag in MarkdownToJSX.HTMLTags]? : HTMLOverride } & {
337
+ [customComponent: string]: HTMLOverride;
338
+ };
339
+ type HTMLOptions = Omit<MarkdownToJSX.Options, "createElement" | "wrapperProps" | "overrides"> & {
340
+ refs?: {
341
+ [key: string]: {
342
+ target: string;
343
+ title: string | undefined;
344
+ };
345
+ };
346
+ renderRule?: (next: () => string, node: MarkdownToJSX.ASTNode, renderChildren: (children: MarkdownToJSX.ASTNode[]) => string, state: MarkdownToJSX.State) => string;
347
+ overrides?: HTMLOverrides;
348
+ wrapperProps?: Record<string, string | number | boolean>;
349
+ };
350
+ declare function astToHTML(nodes: MarkdownToJSX.ASTNode[], options?: HTMLOptions): string;
351
+ /**
352
+ * Compiler function that parses markdown and renders to HTML string
353
+ * Convenience function that combines parser() and html()
354
+ */
355
+ declare function compiler(markdown: string, options?: HTMLOptions): string;
356
+ export { slugify, sanitizer, parser, compiler, astToHTML, RuleType2 as RuleType, MarkdownToJSX, HTMLOverrides, HTMLOverride, HTMLOptions };