@khanacademy/simple-markdown 0.8.2 → 0.8.3
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 +6 -0
- package/dist/es/index.js +6 -3
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/simple-markdown_test.js +27 -0
- package/src/index.js +14 -3
package/CHANGELOG.md
CHANGED
package/dist/es/index.js
CHANGED
|
@@ -174,8 +174,7 @@ var parserFor = function parserFor(rules, defaultState) {
|
|
|
174
174
|
if (capture.index) {
|
|
175
175
|
// If present and non-zero, i.e. a non-^ regexp result:
|
|
176
176
|
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?");
|
|
177
|
-
}
|
|
178
|
-
|
|
177
|
+
}
|
|
179
178
|
|
|
180
179
|
var parsed = rule.parse(capture, nestedParse, state); // We maintain the same object here so that rules can
|
|
181
180
|
// store references to the objects they return and
|
|
@@ -186,10 +185,14 @@ var parserFor = function parserFor(rules, defaultState) {
|
|
|
186
185
|
// $FlowFixMe
|
|
187
186
|
Array.prototype.push.apply(result, parsed);
|
|
188
187
|
} else {
|
|
189
|
-
|
|
188
|
+
if (parsed == null || typeof parsed !== "object") {
|
|
189
|
+
throw new Error("parse() function returned invalid parse result: '".concat(parsed, "'"));
|
|
190
|
+
} // We also let rules override the default type of
|
|
190
191
|
// their parsed node if they would like to, so that
|
|
191
192
|
// there can be a single output function for all links,
|
|
192
193
|
// even if there are several rules to parse them.
|
|
194
|
+
|
|
195
|
+
|
|
193
196
|
if (parsed.type == null) {
|
|
194
197
|
// $FlowFixMe
|
|
195
198
|
parsed.type = ruleType;
|