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