mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Refactor getEvents slightly to avoid modifying the MicromarkParseOptions object.
This commit is contained in:
parent
38b4ec0c2f
commit
d94b78e6bf
2 changed files with 12 additions and 12 deletions
|
|
@ -1023,15 +1023,15 @@ function getEvents(
|
||||||
markdown,
|
markdown,
|
||||||
micromarkParseOptions = {}
|
micromarkParseOptions = {}
|
||||||
) {
|
) {
|
||||||
// Customize options object to add useful extensions
|
// Customize extensions list to add useful extensions
|
||||||
micromarkParseOptions.extensions = micromarkParseOptions.extensions || [];
|
const extensions = [
|
||||||
micromarkParseOptions.extensions.push(
|
|
||||||
micromark.directive(),
|
micromark.directive(),
|
||||||
micromark.gfmAutolinkLiteral(),
|
micromark.gfmAutolinkLiteral(),
|
||||||
micromark.gfmFootnote(),
|
micromark.gfmFootnote(),
|
||||||
micromark.gfmTable(),
|
micromark.gfmTable(),
|
||||||
micromark.math()
|
micromark.math(),
|
||||||
);
|
...(micromarkParseOptions.extensions || [])
|
||||||
|
];
|
||||||
|
|
||||||
// // Shim labelEnd to identify undefined link labels
|
// // Shim labelEnd to identify undefined link labels
|
||||||
/** @type {Event[][]} */
|
/** @type {Event[][]} */
|
||||||
|
|
@ -1153,7 +1153,7 @@ function getEvents(
|
||||||
// Use micromark to parse document into Events
|
// Use micromark to parse document into Events
|
||||||
const encoding = undefined;
|
const encoding = undefined;
|
||||||
const eol = true;
|
const eol = true;
|
||||||
const parseContext = micromark.parse(micromarkParseOptions);
|
const parseContext = micromark.parse({ ...micromarkParseOptions, extensions });
|
||||||
const chunks = micromark.preprocess()(markdown, encoding, eol);
|
const chunks = micromark.preprocess()(markdown, encoding, eol);
|
||||||
const events = micromark.postprocess(parseContext.document().write(chunks));
|
const events = micromark.postprocess(parseContext.document().write(chunks));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,15 +32,15 @@ function getEvents(
|
||||||
markdown,
|
markdown,
|
||||||
micromarkParseOptions = {}
|
micromarkParseOptions = {}
|
||||||
) {
|
) {
|
||||||
// Customize options object to add useful extensions
|
// Customize extensions list to add useful extensions
|
||||||
micromarkParseOptions.extensions = micromarkParseOptions.extensions || [];
|
const extensions = [
|
||||||
micromarkParseOptions.extensions.push(
|
|
||||||
micromark.directive(),
|
micromark.directive(),
|
||||||
micromark.gfmAutolinkLiteral(),
|
micromark.gfmAutolinkLiteral(),
|
||||||
micromark.gfmFootnote(),
|
micromark.gfmFootnote(),
|
||||||
micromark.gfmTable(),
|
micromark.gfmTable(),
|
||||||
micromark.math()
|
micromark.math(),
|
||||||
);
|
...(micromarkParseOptions.extensions || [])
|
||||||
|
];
|
||||||
|
|
||||||
// // Shim labelEnd to identify undefined link labels
|
// // Shim labelEnd to identify undefined link labels
|
||||||
/** @type {Event[][]} */
|
/** @type {Event[][]} */
|
||||||
|
|
@ -162,7 +162,7 @@ function getEvents(
|
||||||
// Use micromark to parse document into Events
|
// Use micromark to parse document into Events
|
||||||
const encoding = undefined;
|
const encoding = undefined;
|
||||||
const eol = true;
|
const eol = true;
|
||||||
const parseContext = micromark.parse(micromarkParseOptions);
|
const parseContext = micromark.parse({ ...micromarkParseOptions, extensions });
|
||||||
const chunks = micromark.preprocess()(markdown, encoding, eol);
|
const chunks = micromark.preprocess()(markdown, encoding, eol);
|
||||||
const events = micromark.postprocess(parseContext.document().write(chunks));
|
const events = micromark.postprocess(parseContext.document().write(chunks));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue