Enable custom rules to use the micromark parser, export micromark helpers for reuse.

This commit is contained in:
David Anson 2024-10-01 22:41:10 -07:00
parent 264da24dae
commit 5cc40c54b7
16 changed files with 4109 additions and 113 deletions

View file

@ -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) => {