mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 14:30:12 +01:00
Update harness.mjs to output micromark token structure.
This commit is contained in:
parent
dce6091503
commit
c8236ed0ea
3 changed files with 32 additions and 43 deletions
|
|
@ -1479,25 +1479,6 @@ function micromarkParse(markdown) {
|
||||||
return document;
|
return document;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Log the structure of a Micromark token list.
|
|
||||||
// *
|
|
||||||
// * @param {Token[]} tokens Micromark tokens.
|
|
||||||
// * @param {number} depth Tree depth.
|
|
||||||
// * @returns {void}
|
|
||||||
// */
|
|
||||||
// function consoleLogTokens(tokens, depth = 0) {
|
|
||||||
// for (const token of tokens) {
|
|
||||||
// const { children, text, type } = token;
|
|
||||||
// console.log(
|
|
||||||
// `${" ".repeat(depth * 2)}${type} ${text.replace(/\n/g, "\\n")}`
|
|
||||||
// );
|
|
||||||
// if (children.length > 0) {
|
|
||||||
// consoleLogTokens(children, depth + 1);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter a list of Micromark tokens by predicate.
|
* Filter a list of Micromark tokens by predicate.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -100,25 +100,6 @@ function micromarkParse(markdown, options = {}, refsDefined = true) {
|
||||||
return document;
|
return document;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Log the structure of a Micromark token list.
|
|
||||||
// *
|
|
||||||
// * @param {Token[]} tokens Micromark tokens.
|
|
||||||
// * @param {number} depth Tree depth.
|
|
||||||
// * @returns {void}
|
|
||||||
// */
|
|
||||||
// function consoleLogTokens(tokens, depth = 0) {
|
|
||||||
// for (const token of tokens) {
|
|
||||||
// const { children, text, type } = token;
|
|
||||||
// console.log(
|
|
||||||
// `${" ".repeat(depth * 2)}${type} ${text.replace(/\n/g, "\\n")}`
|
|
||||||
// );
|
|
||||||
// if (children.length > 0) {
|
|
||||||
// consoleLogTokens(children, depth + 1);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter a list of Micromark tokens by predicate.
|
* Filter a list of Micromark tokens by predicate.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,35 @@
|
||||||
|
import { readFile } from "node:fs/promises";
|
||||||
|
import { parse } from "../helpers/micromark.cjs";
|
||||||
import library from "../lib/markdownlint.js";
|
import library from "../lib/markdownlint.js";
|
||||||
const markdownlint = library.promises.markdownlint;
|
const markdownlint = library.promises.markdownlint;
|
||||||
|
|
||||||
const results = await markdownlint({
|
/* eslint-disable no-await-in-loop, no-console */
|
||||||
"files": process.argv.slice(2)
|
|
||||||
});
|
/**
|
||||||
// eslint-disable-next-line no-console
|
* Log the structure of a Micromark token list.
|
||||||
console.dir(results, { "depth": null });
|
*
|
||||||
|
* @param {Object[]} tokens Micromark tokens.
|
||||||
|
* @param {number} depth Tree depth.
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function consoleLogTokens(tokens, depth = 0) {
|
||||||
|
for (const token of tokens) {
|
||||||
|
const { children, text, type } = token;
|
||||||
|
console.log(
|
||||||
|
`${" ".repeat(depth * 2)}${type} ${text.replace(/\n/g, "\\n")}`
|
||||||
|
);
|
||||||
|
if (children.length > 0) {
|
||||||
|
consoleLogTokens(children, depth + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const files = process.argv.slice(2);
|
||||||
|
for (const file of files) {
|
||||||
|
const content = await readFile(file);
|
||||||
|
consoleLogTokens(parse(content));
|
||||||
|
const results = await markdownlint({
|
||||||
|
"files": [ file ]
|
||||||
|
});
|
||||||
|
console.dir(results, { "depth": null });
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue