diff --git a/demo/markdownlint-browser.js b/demo/markdownlint-browser.js index fb825c4f..b224ec09 100644 --- a/demo/markdownlint-browser.js +++ b/demo/markdownlint-browser.js @@ -1479,25 +1479,6 @@ function micromarkParse(markdown) { 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. * diff --git a/helpers/micromark.cjs b/helpers/micromark.cjs index ebbefad1..3876965e 100644 --- a/helpers/micromark.cjs +++ b/helpers/micromark.cjs @@ -100,25 +100,6 @@ function micromarkParse(markdown, options = {}, refsDefined = true) { 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. * diff --git a/test/harness.mjs b/test/harness.mjs index 3ac30fd2..30ae25d7 100644 --- a/test/harness.mjs +++ b/test/harness.mjs @@ -1,8 +1,35 @@ +import { readFile } from "node:fs/promises"; +import { parse } from "../helpers/micromark.cjs"; import library from "../lib/markdownlint.js"; const markdownlint = library.promises.markdownlint; -const results = await markdownlint({ - "files": process.argv.slice(2) -}); -// eslint-disable-next-line no-console -console.dir(results, { "depth": null }); +/* eslint-disable no-await-in-loop, no-console */ + +/** + * Log the structure of a Micromark token list. + * + * @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 }); +}