@khanacademy/simple-markdown 0.9.4 → 0.10.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/CHANGELOG.md +14 -1
- package/dist/es/index.js +23 -39
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +26 -39
- package/dist/index.js.map +1 -1
- package/dist/version.d.ts +1 -0
- package/package.json +5 -3
- package/src/__tests__/simple-markdown.test.ts +5 -5
- package/src/index.ts +24 -22
- package/src/version.ts +10 -0
- package/tsconfig-build.json +3 -1
- package/tsconfig-build.tsbuildinfo +1 -1
- package/dist/index.js.flow +0 -267
- package/dist/troublesome-types.js.flow +0 -22
- package/src/troublesome-types.js.flow +0 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
# @khanacademy/simple-markdown
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.10.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 55d4cd00: Print package name and version when loaded in the page
|
|
8
|
+
- Updated dependencies [55d4cd00]
|
|
9
|
+
- @khanacademy/perseus-core@1.1.1
|
|
10
|
+
|
|
11
|
+
## 0.10.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- 0993a46b: Don't generate Flow types
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
6
18
|
|
|
7
19
|
- afb14cff: Add eslint rule to make type imports consistent
|
|
20
|
+
- ce5e6297: Upgrade wonder-blocks deps to package versions without Flow types
|
|
8
21
|
|
|
9
22
|
## 0.9.3
|
|
10
23
|
|
package/dist/es/index.js
CHANGED
|
@@ -1,30 +1,14 @@
|
|
|
1
|
+
import { addLibraryVersionToPerseusDebug } from '@khanacademy/perseus-core';
|
|
2
|
+
|
|
3
|
+
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
4
|
+
const libName = "@khanacademy/simple-markdown";
|
|
5
|
+
const libVersion = "0.10.1";
|
|
6
|
+
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
7
|
+
|
|
1
8
|
/* eslint-disable prefer-spread, no-regex-spaces, @typescript-eslint/no-unused-vars, guard-for-in, no-console, no-var */
|
|
2
|
-
/**
|
|
3
|
-
* Simple-Markdown
|
|
4
|
-
* ===============
|
|
5
|
-
*
|
|
6
|
-
* Simple-Markdown's primary goal is to be easy to adapt. It aims
|
|
7
|
-
* to be compliant with John Gruber's [Markdown Syntax page][1],
|
|
8
|
-
* but compatiblity with other markdown implementations' edge-cases
|
|
9
|
-
* will be sacrificed where it conflicts with simplicity or
|
|
10
|
-
* extensibility.
|
|
11
|
-
*
|
|
12
|
-
* If your goal is to simply embed a standard markdown implementation
|
|
13
|
-
* in your website, simple-markdown is probably not the best library
|
|
14
|
-
* for you (although it should work). But if you have struggled to
|
|
15
|
-
* customize an existing library to meet your needs, simple-markdown
|
|
16
|
-
* might be able to help.
|
|
17
|
-
*
|
|
18
|
-
* Many of the regexes and original logic has been adapted from
|
|
19
|
-
* the wonderful [marked.js](https://github.com/chjj/marked)
|
|
20
|
-
*/
|
|
21
9
|
|
|
22
10
|
// Type Definitions:
|
|
23
11
|
|
|
24
|
-
// We want to clarify our defaultRules types a little bit more so clients can
|
|
25
|
-
// reuse defaultRules built-ins. So we make some stronger guarantess when
|
|
26
|
-
// we can:
|
|
27
|
-
|
|
28
12
|
// End TypeScript Definitions
|
|
29
13
|
|
|
30
14
|
var CR_NEWLINE_R = /\r\n?/g;
|
|
@@ -134,11 +118,11 @@ var parserFor = function parserFor(rules, defaultState) {
|
|
|
134
118
|
// the initial quality is NaN (that's why there's the
|
|
135
119
|
// condition negation).
|
|
136
120
|
if (!(currQuality <= quality)) {
|
|
137
|
-
// @ts-expect-error
|
|
121
|
+
// @ts-expect-error - TS2322 - Type 'string' is not assignable to type 'null'.
|
|
138
122
|
ruleType = currRuleType;
|
|
139
|
-
// @ts-expect-error
|
|
123
|
+
// @ts-expect-error - TS2322 - Type 'ParserRule' is not assignable to type 'null'.
|
|
140
124
|
rule = currRule;
|
|
141
|
-
// @ts-expect-error
|
|
125
|
+
// @ts-expect-error - TS2322 - Type 'Capture' is not assignable to type 'null'.
|
|
142
126
|
capture = currCapture;
|
|
143
127
|
quality = currQuality;
|
|
144
128
|
}
|
|
@@ -166,13 +150,13 @@ var parserFor = function parserFor(rules, defaultState) {
|
|
|
166
150
|
if (rule == null || capture == null) {
|
|
167
151
|
throw new Error("Could not find a matching rule for the below " + "content. The rule with highest `order` should " + "always match content provided to it. Check " + "the definition of `match` for '" + ruleList[ruleList.length - 1] + "'. It seems to not match the following source:\n" + source);
|
|
168
152
|
}
|
|
169
|
-
// @ts-expect-error
|
|
153
|
+
// @ts-expect-error - TS2339 - Property 'index' does not exist on type 'never'.
|
|
170
154
|
if (capture.index) {
|
|
171
155
|
// If present and non-zero, i.e. a non-^ regexp result:
|
|
172
156
|
throw new Error("`match` must return a capture starting at index 0 " + "(the current parse index). Did you forget a ^ at the " + "start of the RegExp?");
|
|
173
157
|
}
|
|
174
158
|
|
|
175
|
-
// @ts-expect-error
|
|
159
|
+
// @ts-expect-error - TS2339 - Property 'parse' does not exist on type 'never'.
|
|
176
160
|
var parsed = rule.parse(capture, nestedParse, state);
|
|
177
161
|
// We maintain the same object here so that rules can
|
|
178
162
|
// store references to the objects they return and
|
|
@@ -224,7 +208,7 @@ var inlineRegex = function inlineRegex(regex) {
|
|
|
224
208
|
return null;
|
|
225
209
|
}
|
|
226
210
|
};
|
|
227
|
-
// @ts-expect-error
|
|
211
|
+
// @ts-expect-error - TS2339 - Property 'regex' does not exist on type '(source: string, state: State, prevCapture: string) => Capture | null | undefined'.
|
|
228
212
|
match.regex = regex;
|
|
229
213
|
return match;
|
|
230
214
|
};
|
|
@@ -430,7 +414,7 @@ var TABLES = function () {
|
|
|
430
414
|
if (node.type === "text" && (tableRow[i + 1] == null || tableRow[i + 1].type === "tableSeparator")) {
|
|
431
415
|
node.content = node.content.replace(TABLE_CELL_END_TRIM, "");
|
|
432
416
|
}
|
|
433
|
-
// @ts-expect-error
|
|
417
|
+
// @ts-expect-error - TS2345 - Argument of type 'SingleASTNode' is not assignable to parameter of type 'never'.
|
|
434
418
|
cells[cells.length - 1].push(node);
|
|
435
419
|
}
|
|
436
420
|
});
|
|
@@ -689,7 +673,7 @@ var defaultRules = {
|
|
|
689
673
|
var bullet = capture[2];
|
|
690
674
|
var ordered = bullet.length > 1;
|
|
691
675
|
var start = ordered ? +bullet : undefined;
|
|
692
|
-
// @ts-expect-error
|
|
676
|
+
// @ts-expect-error - TS2322 - Type 'RegExpMatchArray | null' is not assignable to type 'string[]'.
|
|
693
677
|
var items = capture[0].replace(LIST_BLOCK_END_R, "\n").match(LIST_ITEM_R);
|
|
694
678
|
|
|
695
679
|
// We know this will match here, because of how the regexes are
|
|
@@ -1246,7 +1230,7 @@ var ruleOutput = function ruleOutput(rules, property) {
|
|
|
1246
1230
|
console.warn("simple-markdown ruleOutput should take 'react' or " + "'html' as the second argument.");
|
|
1247
1231
|
}
|
|
1248
1232
|
var nestedRuleOutput = function nestedRuleOutput(ast, outputFunc, state) {
|
|
1249
|
-
// @ts-expect-error
|
|
1233
|
+
// @ts-expect-error - TS2349 - This expression is not callable.
|
|
1250
1234
|
// Type 'unknown' has no call signatures.
|
|
1251
1235
|
return rules[ast.type][property](ast, outputFunc, state);
|
|
1252
1236
|
};
|
|
@@ -1269,12 +1253,12 @@ var reactFor = function reactFor(outputFunc) {
|
|
|
1269
1253
|
state.key = "" + i;
|
|
1270
1254
|
var nodeOut = nestedOutput(ast[i], state);
|
|
1271
1255
|
if (typeof nodeOut === "string" && typeof lastResult === "string") {
|
|
1272
|
-
// @ts-expect-error
|
|
1256
|
+
// @ts-expect-error - TS2322 - Type 'string' is not assignable to type 'null'.
|
|
1273
1257
|
lastResult = lastResult + nodeOut;
|
|
1274
1258
|
result[result.length - 1] = lastResult;
|
|
1275
1259
|
} else {
|
|
1276
1260
|
result.push(nodeOut);
|
|
1277
|
-
// @ts-expect-error
|
|
1261
|
+
// @ts-expect-error - TS2322 - Type 'ReactNode' is not assignable to type 'null'.
|
|
1278
1262
|
lastResult = nodeOut;
|
|
1279
1263
|
}
|
|
1280
1264
|
}
|
|
@@ -1310,11 +1294,11 @@ var outputFor = function outputFor(rules, property, defaultState = {}) {
|
|
|
1310
1294
|
var arrayRule = rules.Array || defaultRules.Array;
|
|
1311
1295
|
|
|
1312
1296
|
// Tricks to convince tsc that this var is not null:
|
|
1313
|
-
// @ts-expect-error
|
|
1297
|
+
// @ts-expect-error - TS2538 - Type 'symbol' cannot be used as an index type.
|
|
1314
1298
|
var arrayRuleCheck = arrayRule[property];
|
|
1315
1299
|
if (!arrayRuleCheck) {
|
|
1316
1300
|
throw new Error("simple-markdown: outputFor: to join nodes of type `" +
|
|
1317
|
-
// @ts-expect-error
|
|
1301
|
+
// @ts-expect-error - TS2469 - The '+' operator cannot be applied to type 'symbol'.
|
|
1318
1302
|
property + "` you must provide an `Array:` joiner rule with that type, " + "Please see the docs for details on specifying an Array rule.");
|
|
1319
1303
|
}
|
|
1320
1304
|
var arrayRuleOutput = arrayRuleCheck;
|
|
@@ -1324,7 +1308,7 @@ var outputFor = function outputFor(rules, property, defaultState = {}) {
|
|
|
1324
1308
|
if (Array.isArray(ast)) {
|
|
1325
1309
|
return arrayRuleOutput(ast, nestedOutput, state);
|
|
1326
1310
|
} else {
|
|
1327
|
-
// @ts-expect-error
|
|
1311
|
+
// @ts-expect-error - TS2349 - This expression is not callable.
|
|
1328
1312
|
// Type 'unknown' has no call signatures.
|
|
1329
1313
|
return rules[ast.type][property](ast, nestedOutput, state);
|
|
1330
1314
|
}
|
|
@@ -1336,7 +1320,7 @@ var outputFor = function outputFor(rules, property, defaultState = {}) {
|
|
|
1336
1320
|
return outerOutput;
|
|
1337
1321
|
};
|
|
1338
1322
|
|
|
1339
|
-
// @ts-expect-error
|
|
1323
|
+
// @ts-expect-error - TS2345 - Argument of type 'DefaultRules' is not assignable to parameter of type 'ParserRules'.
|
|
1340
1324
|
var defaultRawParse = parserFor(defaultRules);
|
|
1341
1325
|
var defaultBlockParse = function defaultBlockParse(source, state) {
|
|
1342
1326
|
state = state || {};
|
|
@@ -1418,5 +1402,5 @@ var SimpleMarkdown = {
|
|
|
1418
1402
|
}
|
|
1419
1403
|
};
|
|
1420
1404
|
|
|
1421
|
-
export { SimpleMarkdown as default };
|
|
1405
|
+
export { SimpleMarkdown as default, libVersion };
|
|
1422
1406
|
//# sourceMappingURL=index.js.map
|