@khanacademy/simple-markdown 0.14.1 → 2.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.
- package/dist/es/index.js +36 -3
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +37 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -5,11 +5,34 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var perseusUtils = require('@khanacademy/perseus-utils');
|
|
6
6
|
|
|
7
7
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
8
|
+
// version number during the release build.
|
|
9
|
+
// In dev, you'll never see the version number.
|
|
10
|
+
|
|
8
11
|
const libName = "@khanacademy/simple-markdown";
|
|
9
|
-
const libVersion = "0.
|
|
12
|
+
const libVersion = "2.0.0";
|
|
10
13
|
perseusUtils.addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
11
14
|
|
|
12
15
|
/* eslint-disable prefer-spread, no-regex-spaces, guard-for-in, no-console, no-var */
|
|
16
|
+
/**
|
|
17
|
+
* Simple-Markdown
|
|
18
|
+
* ===============
|
|
19
|
+
*
|
|
20
|
+
* Simple-Markdown's primary goal is to be easy to adapt. It aims
|
|
21
|
+
* to be compliant with John Gruber's [Markdown Syntax page][1],
|
|
22
|
+
* but compatiblity with other markdown implementations' edge-cases
|
|
23
|
+
* will be sacrificed where it conflicts with simplicity or
|
|
24
|
+
* extensibility.
|
|
25
|
+
*
|
|
26
|
+
* If your goal is to simply embed a standard markdown implementation
|
|
27
|
+
* in your website, simple-markdown is probably not the best library
|
|
28
|
+
* for you (although it should work). But if you have struggled to
|
|
29
|
+
* customize an existing library to meet your needs, simple-markdown
|
|
30
|
+
* might be able to help.
|
|
31
|
+
*
|
|
32
|
+
* Many of the regexes and original logic has been adapted from
|
|
33
|
+
* the wonderful [marked.js](https://github.com/chjj/marked)
|
|
34
|
+
*/
|
|
35
|
+
|
|
13
36
|
|
|
14
37
|
// Type Definitions:
|
|
15
38
|
|
|
@@ -143,8 +166,10 @@ var parserFor = function (rules, defaultState) {
|
|
|
143
166
|
currRule = rules[currRuleType];
|
|
144
167
|
} while (
|
|
145
168
|
// keep looping while we're still within the ruleList
|
|
169
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
146
170
|
currRule && (
|
|
147
171
|
// if we don't have a match yet, continue
|
|
172
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
148
173
|
!capture ||
|
|
149
174
|
// or if we have a match, but the next rule is
|
|
150
175
|
// at the same order, and has a quality measurement
|
|
@@ -242,7 +267,11 @@ var anyScopeRegex = function (regex) {
|
|
|
242
267
|
match.regex = regex;
|
|
243
268
|
return match;
|
|
244
269
|
};
|
|
245
|
-
var TYPE_SYMBOL = typeof Symbol === "function" &&
|
|
270
|
+
var TYPE_SYMBOL = typeof Symbol === "function" &&
|
|
271
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
272
|
+
Symbol.for &&
|
|
273
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
274
|
+
Symbol.for("react.element") || 0xeac7;
|
|
246
275
|
var reactElement = function (type, key, props) {
|
|
247
276
|
var element = {
|
|
248
277
|
$$typeof: TYPE_SYMBOL,
|
|
@@ -270,7 +299,9 @@ var htmlTag = function (tagName, content, attributes, isClosed) {
|
|
|
270
299
|
for (var attr in attributes) {
|
|
271
300
|
var attribute = attributes[attr];
|
|
272
301
|
// Removes falsey attributes
|
|
273
|
-
if (Object.prototype.hasOwnProperty.call(attributes, attr) &&
|
|
302
|
+
if (Object.prototype.hasOwnProperty.call(attributes, attr) &&
|
|
303
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
304
|
+
attribute) {
|
|
274
305
|
attributeString += " " + sanitizeText(attr) + '="' + sanitizeText(attribute) + '"';
|
|
275
306
|
}
|
|
276
307
|
}
|
|
@@ -1239,6 +1270,7 @@ var defaultRules = {
|
|
|
1239
1270
|
|
|
1240
1271
|
/** (deprecated) */
|
|
1241
1272
|
var ruleOutput = function (rules, property) {
|
|
1273
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
1242
1274
|
if (!property && typeof console !== "undefined") {
|
|
1243
1275
|
console.warn("simple-markdown ruleOutput should take 'react' or " + "'html' as the second argument.");
|
|
1244
1276
|
}
|
|
@@ -1301,6 +1333,7 @@ var htmlFor = function (outputFunc) {
|
|
|
1301
1333
|
};
|
|
1302
1334
|
var outputFor = function (rules, property) {
|
|
1303
1335
|
let defaultState = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1336
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
1304
1337
|
if (!property) {
|
|
1305
1338
|
throw new Error("simple-markdown: outputFor: `property` must be " + "defined. " + "if you just upgraded, you probably need to replace `outputFor` " + "with `reactFor`");
|
|
1306
1339
|
}
|
|
@@ -1424,6 +1457,6 @@ var SimpleMarkdown = {
|
|
|
1424
1457
|
}
|
|
1425
1458
|
};
|
|
1426
1459
|
|
|
1427
|
-
exports
|
|
1460
|
+
exports.default = SimpleMarkdown;
|
|
1428
1461
|
exports.libVersion = libVersion;
|
|
1429
1462
|
//# sourceMappingURL=index.js.map
|