mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Enable custom rules to use the micromark parser, export micromark helpers for reuse.
This commit is contained in:
parent
264da24dae
commit
5cc40c54b7
16 changed files with 4109 additions and 113 deletions
|
|
@ -17,26 +17,9 @@ const testTokens = new Promise((resolve, reject) => {
|
|||
testContent.then(parse).then(resolve, reject);
|
||||
});
|
||||
|
||||
const cloneToken = (token) => {
|
||||
for (const child of token.children) {
|
||||
const expectedParent = (token.type ? token : null);
|
||||
if (child.parent !== expectedParent) {
|
||||
throw new Error("Unexpected parent.");
|
||||
}
|
||||
}
|
||||
const clone = { ...token };
|
||||
delete clone.parent;
|
||||
clone.children = clone.children.map(cloneToken);
|
||||
return clone;
|
||||
};
|
||||
|
||||
const cloneTokens = (tokens) => (
|
||||
cloneToken({ "children": tokens }).children
|
||||
);
|
||||
|
||||
test("parse", async(t) => {
|
||||
t.plan(1);
|
||||
t.snapshot(cloneTokens(await testTokens), "Unexpected tokens");
|
||||
t.snapshot(await testTokens, "Unexpected tokens");
|
||||
});
|
||||
|
||||
test("getEvents/filterByPredicate", async(t) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue