Stop running the markdown-it parser unless a custom rule that requires it is present (~7% runtime reduction).

This commit is contained in:
David Anson 2024-08-21 21:19:40 -07:00
parent 697780b3b6
commit ea8d596a9b
5 changed files with 102 additions and 36 deletions

View file

@ -1109,6 +1109,8 @@ test("markdownItPluginsSingle", (t) => new Promise((resolve) => {
"strings": {
"string": "# Heading\n\nText\n"
},
// Use a markdown-it custom rule so the markdown-it plugin will be run
"customRules": customRules.anyBlockquote,
"markdownItPlugins": [
[ pluginInline, "check_text_plugin", "text", () => t.true(true) ]
]
@ -1126,6 +1128,8 @@ test("markdownItPluginsMultiple", (t) => new Promise((resolve) => {
"strings": {
"string": "# Heading\n\nText H~2~0 text 29^th^ text\n"
},
// Use a markdown-it custom rule so the markdown-it plugin will be run
"customRules": customRules.anyBlockquote,
"markdownItPlugins": [
[ pluginSub ],
[ pluginSup ],
@ -1140,6 +1144,23 @@ test("markdownItPluginsMultiple", (t) => new Promise((resolve) => {
});
}));
test("markdownItPluginsNoMarkdownIt", (t) => new Promise((resolve) => {
t.plan(2);
markdownlint({
"strings": {
"string": "# Heading\n\nText\n"
},
"markdownItPlugins": [
[ pluginInline, "check_text_plugin", "text", () => t.fail() ]
]
}, function callback(err, actual) {
t.falsy(err);
const expected = { "string": [] };
t.deepEqual(actual, expected, "Unexpected issues.");
resolve();
});
}));
test("Pandoc footnote", (t) => new Promise((resolve) => {
t.plan(2);
markdownlint({