@khanacademy/simple-markdown 0.8.5 → 0.9.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/.eslintrc.js +7 -1
- package/CHANGELOG.md +13 -0
- package/dist/es/index.js +194 -280
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +187 -2
- package/dist/index.js +194 -244
- package/dist/index.js.flow +282 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/{simple-markdown_test.js → simple-markdown.test.ts} +39 -53
- package/src/{index.js → index.ts} +250 -187
- package/tsconfig.json +6 -68
- package/tsconfig.tsbuildinfo +1 -0
package/dist/index.js.flow
CHANGED
|
@@ -1,2 +1,282 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for data
|
|
3
|
+
* Generated by Flowgen from a Typescript Definition
|
|
4
|
+
* Flowgen v1.21.0
|
|
5
|
+
* @flow
|
|
6
|
+
*/
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
declare type Capture =
|
|
9
|
+
| {|
|
|
10
|
+
...Array<string>,
|
|
11
|
+
...{|
|
|
12
|
+
index: number,
|
|
13
|
+
|},
|
|
14
|
+
|}
|
|
15
|
+
| {|
|
|
16
|
+
...Array<string>,
|
|
17
|
+
...{|
|
|
18
|
+
index?: number,
|
|
19
|
+
|},
|
|
20
|
+
|};
|
|
21
|
+
declare type Attr = string | number | boolean | null | void;
|
|
22
|
+
declare type SingleASTNode = {
|
|
23
|
+
type: string,
|
|
24
|
+
[key: string]: any,
|
|
25
|
+
};
|
|
26
|
+
declare type UnTypedASTNode = {
|
|
27
|
+
[key: string]: any,
|
|
28
|
+
};
|
|
29
|
+
declare type ASTNode = SingleASTNode | Array<SingleASTNode>;
|
|
30
|
+
declare type State = {
|
|
31
|
+
key?: string | number | void,
|
|
32
|
+
inline?: boolean | null | void,
|
|
33
|
+
[key: string]: any,
|
|
34
|
+
};
|
|
35
|
+
declare type ReactElement = React.Element<any>;
|
|
36
|
+
declare type ReactElements = React.Node;
|
|
37
|
+
declare type MatchFunction = {|
|
|
38
|
+
...{|
|
|
39
|
+
regex?: RegExp,
|
|
40
|
+
|},
|
|
41
|
+
...(
|
|
42
|
+
source: string,
|
|
43
|
+
state: State,
|
|
44
|
+
prevCapture: string
|
|
45
|
+
) => Capture | null | void,
|
|
46
|
+
|};
|
|
47
|
+
declare type Parser = (
|
|
48
|
+
source: string,
|
|
49
|
+
state?: State | null | void
|
|
50
|
+
) => Array<SingleASTNode>;
|
|
51
|
+
declare type ParseFunction = (
|
|
52
|
+
capture: Capture,
|
|
53
|
+
nestedParse: Parser,
|
|
54
|
+
state: State
|
|
55
|
+
) => UnTypedASTNode | ASTNode;
|
|
56
|
+
declare type SingleNodeParseFunction = (
|
|
57
|
+
capture: Capture,
|
|
58
|
+
nestedParse: Parser,
|
|
59
|
+
state: State
|
|
60
|
+
) => UnTypedASTNode;
|
|
61
|
+
declare type Output<Result> = (
|
|
62
|
+
node: ASTNode,
|
|
63
|
+
state?: State | null | void
|
|
64
|
+
) => Result;
|
|
65
|
+
declare type NodeOutput<Result> = (
|
|
66
|
+
node: SingleASTNode,
|
|
67
|
+
nestedOutput: Output<Result>,
|
|
68
|
+
state: State
|
|
69
|
+
) => Result;
|
|
70
|
+
declare type ArrayNodeOutput<Result> = (
|
|
71
|
+
node: Array<SingleASTNode>,
|
|
72
|
+
nestedOutput: Output<Result>,
|
|
73
|
+
state: State
|
|
74
|
+
) => Result;
|
|
75
|
+
declare type ReactOutput = Output<ReactElements>;
|
|
76
|
+
declare type ReactNodeOutput = NodeOutput<ReactElements>;
|
|
77
|
+
declare type HtmlOutput = Output<string>;
|
|
78
|
+
declare type HtmlNodeOutput = NodeOutput<string>;
|
|
79
|
+
declare type ParserRule = {|
|
|
80
|
+
+order: number,
|
|
81
|
+
+match: MatchFunction,
|
|
82
|
+
+quality?: (capture: Capture, state: State, prevCapture: string) => number,
|
|
83
|
+
+parse: ParseFunction,
|
|
84
|
+
|};
|
|
85
|
+
declare type SingleNodeParserRule = {|
|
|
86
|
+
+order: number,
|
|
87
|
+
+match: MatchFunction,
|
|
88
|
+
+quality?: (capture: Capture, state: State, prevCapture: string) => number,
|
|
89
|
+
+parse: SingleNodeParseFunction,
|
|
90
|
+
|};
|
|
91
|
+
declare type ReactOutputRule = {|
|
|
92
|
+
+react: ReactNodeOutput | null,
|
|
93
|
+
|};
|
|
94
|
+
declare type HtmlOutputRule = {|
|
|
95
|
+
+html: HtmlNodeOutput | null,
|
|
96
|
+
|};
|
|
97
|
+
declare type ArrayRule = {
|
|
98
|
+
+react?: ArrayNodeOutput<ReactElements>,
|
|
99
|
+
+html?: ArrayNodeOutput<string>,
|
|
100
|
+
+[key: string]: ArrayNodeOutput<any>,
|
|
101
|
+
};
|
|
102
|
+
declare type ParserRules = {
|
|
103
|
+
+Array?: ArrayRule,
|
|
104
|
+
+[type: string]: ParserRule,
|
|
105
|
+
};
|
|
106
|
+
declare type OutputRules<Rule> = {
|
|
107
|
+
+Array?: ArrayRule,
|
|
108
|
+
+[type: string]: Rule,
|
|
109
|
+
};
|
|
110
|
+
declare type Rules<OutputRule> = {
|
|
111
|
+
+Array?: ArrayRule,
|
|
112
|
+
+[type: string]: {| ...ParserRule, ...OutputRule |},
|
|
113
|
+
};
|
|
114
|
+
declare type ReactRules = {
|
|
115
|
+
+Array?: {|
|
|
116
|
+
+react: ArrayNodeOutput<ReactElements>,
|
|
117
|
+
|},
|
|
118
|
+
+[type: string]: {| ...ParserRule, ...ReactOutputRule |},
|
|
119
|
+
};
|
|
120
|
+
declare type HtmlRules = {
|
|
121
|
+
+Array?: {|
|
|
122
|
+
+html: ArrayNodeOutput<string>,
|
|
123
|
+
|},
|
|
124
|
+
+[type: string]: {| ...ParserRule, ...HtmlOutputRule |},
|
|
125
|
+
};
|
|
126
|
+
declare type NonNullReactOutputRule = {|
|
|
127
|
+
+react: ReactNodeOutput,
|
|
128
|
+
|};
|
|
129
|
+
declare type ElementReactOutputRule = {|
|
|
130
|
+
+react: NodeOutput<ReactElement>,
|
|
131
|
+
|};
|
|
132
|
+
declare type TextReactOutputRule = {|
|
|
133
|
+
+react: NodeOutput<string>,
|
|
134
|
+
|};
|
|
135
|
+
declare type NonNullHtmlOutputRule = {|
|
|
136
|
+
+html: HtmlNodeOutput,
|
|
137
|
+
|};
|
|
138
|
+
declare type DefaultInRule = {|
|
|
139
|
+
...SingleNodeParserRule,
|
|
140
|
+
...ReactOutputRule,
|
|
141
|
+
...HtmlOutputRule,
|
|
142
|
+
|};
|
|
143
|
+
declare type TextInOutRule = {|
|
|
144
|
+
...SingleNodeParserRule,
|
|
145
|
+
...TextReactOutputRule,
|
|
146
|
+
...NonNullHtmlOutputRule,
|
|
147
|
+
|};
|
|
148
|
+
declare type LenientInOutRule = {|
|
|
149
|
+
...SingleNodeParserRule,
|
|
150
|
+
...NonNullReactOutputRule,
|
|
151
|
+
...NonNullHtmlOutputRule,
|
|
152
|
+
|};
|
|
153
|
+
declare type DefaultInOutRule = {|
|
|
154
|
+
...SingleNodeParserRule,
|
|
155
|
+
...ElementReactOutputRule,
|
|
156
|
+
...NonNullHtmlOutputRule,
|
|
157
|
+
|};
|
|
158
|
+
declare type DefaultRules = {|
|
|
159
|
+
+Array: {|
|
|
160
|
+
+react: ArrayNodeOutput<ReactElements>,
|
|
161
|
+
+html: ArrayNodeOutput<string>,
|
|
162
|
+
|},
|
|
163
|
+
+heading: DefaultInOutRule,
|
|
164
|
+
+nptable: DefaultInRule,
|
|
165
|
+
+lheading: DefaultInRule,
|
|
166
|
+
+hr: DefaultInOutRule,
|
|
167
|
+
+codeBlock: DefaultInOutRule,
|
|
168
|
+
+fence: DefaultInRule,
|
|
169
|
+
+blockQuote: DefaultInOutRule,
|
|
170
|
+
+list: DefaultInOutRule,
|
|
171
|
+
+def: LenientInOutRule,
|
|
172
|
+
+table: DefaultInOutRule,
|
|
173
|
+
+tableSeparator: DefaultInRule,
|
|
174
|
+
+newline: TextInOutRule,
|
|
175
|
+
+paragraph: DefaultInOutRule,
|
|
176
|
+
+escape: DefaultInRule,
|
|
177
|
+
+autolink: DefaultInRule,
|
|
178
|
+
+mailto: DefaultInRule,
|
|
179
|
+
+url: DefaultInRule,
|
|
180
|
+
+link: DefaultInOutRule,
|
|
181
|
+
+image: DefaultInOutRule,
|
|
182
|
+
+reflink: DefaultInRule,
|
|
183
|
+
+refimage: DefaultInRule,
|
|
184
|
+
+em: DefaultInOutRule,
|
|
185
|
+
+strong: DefaultInOutRule,
|
|
186
|
+
+u: DefaultInOutRule,
|
|
187
|
+
+del: DefaultInOutRule,
|
|
188
|
+
+inlineCode: DefaultInOutRule,
|
|
189
|
+
+br: DefaultInOutRule,
|
|
190
|
+
+text: TextInOutRule,
|
|
191
|
+
|};
|
|
192
|
+
declare type Exports = {|
|
|
193
|
+
+defaultRules: DefaultRules,
|
|
194
|
+
+parserFor: (
|
|
195
|
+
rules: ParserRules,
|
|
196
|
+
defaultState?: State | null | void
|
|
197
|
+
) => Parser,
|
|
198
|
+
+outputFor: <Rule>(
|
|
199
|
+
rules: OutputRules<Rule>,
|
|
200
|
+
param: $Keys<Rule>,
|
|
201
|
+
defaultState?: State | null | void
|
|
202
|
+
) => Output<any>,
|
|
203
|
+
+ruleOutput: <Rule>(
|
|
204
|
+
rules: OutputRules<Rule>,
|
|
205
|
+
param: $Keys<Rule>
|
|
206
|
+
) => NodeOutput<any>,
|
|
207
|
+
+reactFor: (arg1: ReactNodeOutput) => ReactOutput,
|
|
208
|
+
+htmlFor: (arg1: HtmlNodeOutput) => HtmlOutput,
|
|
209
|
+
+inlineRegex: (regex: RegExp) => MatchFunction,
|
|
210
|
+
+blockRegex: (regex: RegExp) => MatchFunction,
|
|
211
|
+
+anyScopeRegex: (regex: RegExp) => MatchFunction,
|
|
212
|
+
+parseInline: (parse: Parser, content: string, state: State) => ASTNode,
|
|
213
|
+
+parseBlock: (parse: Parser, content: string, state: State) => ASTNode,
|
|
214
|
+
+markdownToReact: (
|
|
215
|
+
source: string,
|
|
216
|
+
state?: State | null | void
|
|
217
|
+
) => ReactElements,
|
|
218
|
+
+markdownToHtml: (source: string, state?: State | null | void) => string,
|
|
219
|
+
+ReactMarkdown: (props: {
|
|
220
|
+
source: string,
|
|
221
|
+
[key: string]: any,
|
|
222
|
+
}) => ReactElement,
|
|
223
|
+
+defaultRawParse: (
|
|
224
|
+
source: string,
|
|
225
|
+
state?: State | null | void
|
|
226
|
+
) => Array<SingleASTNode>,
|
|
227
|
+
+defaultBlockParse: (
|
|
228
|
+
source: string,
|
|
229
|
+
state?: State | null | void
|
|
230
|
+
) => Array<SingleASTNode>,
|
|
231
|
+
+defaultInlineParse: (
|
|
232
|
+
source: string,
|
|
233
|
+
state?: State | null | void
|
|
234
|
+
) => Array<SingleASTNode>,
|
|
235
|
+
+defaultImplicitParse: (
|
|
236
|
+
source: string,
|
|
237
|
+
state?: State | null | void
|
|
238
|
+
) => Array<SingleASTNode>,
|
|
239
|
+
+defaultReactOutput: ReactOutput,
|
|
240
|
+
+defaultHtmlOutput: HtmlOutput,
|
|
241
|
+
+preprocess: (source: string) => string,
|
|
242
|
+
+sanitizeText: (text: Attr) => string,
|
|
243
|
+
+sanitizeUrl: (url?: string | null | void) => string | null | void,
|
|
244
|
+
+unescapeUrl: (url: string) => string,
|
|
245
|
+
+htmlTag: (
|
|
246
|
+
tagName: string,
|
|
247
|
+
content: string,
|
|
248
|
+
attributes?: $Rest<{ [key: any]: Attr | null | void }, {}> | null | void,
|
|
249
|
+
isClosed?: boolean | null | void
|
|
250
|
+
) => string,
|
|
251
|
+
+reactElement: (
|
|
252
|
+
type: string,
|
|
253
|
+
key: string | null,
|
|
254
|
+
props: {
|
|
255
|
+
[key: string]: any,
|
|
256
|
+
}
|
|
257
|
+
) => ReactElement,
|
|
258
|
+
|};
|
|
259
|
+
export type {
|
|
260
|
+
State,
|
|
261
|
+
Parser,
|
|
262
|
+
Output,
|
|
263
|
+
ReactOutput,
|
|
264
|
+
HtmlOutput,
|
|
265
|
+
Capture,
|
|
266
|
+
MatchFunction,
|
|
267
|
+
ParseFunction,
|
|
268
|
+
NodeOutput,
|
|
269
|
+
ArrayNodeOutput,
|
|
270
|
+
ReactNodeOutput,
|
|
271
|
+
ParserRule,
|
|
272
|
+
ReactOutputRule,
|
|
273
|
+
HtmlOutputRule,
|
|
274
|
+
ParserRules,
|
|
275
|
+
OutputRules,
|
|
276
|
+
Rules,
|
|
277
|
+
ReactRules,
|
|
278
|
+
HtmlRules,
|
|
279
|
+
SingleASTNode,
|
|
280
|
+
};
|
|
281
|
+
declare var SimpleMarkdown: Exports;
|
|
282
|
+
declare export default typeof SimpleMarkdown;
|