markdown-task-checker
Version:
A CLI tool to check markdown task list completion
15 lines (14 loc) • 497 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseMarkdownTasks = parseMarkdownTasks;
function parseMarkdownTasks(content) {
const taskRegex = /^\s*[-*]\s+\[( |x|X)]\s+/gm;
const matches = [...content.matchAll(taskRegex)];
const total = matches.length;
const checked = matches.filter((match) => match[1].toLowerCase() === "x").length;
return {
total,
checked,
allChecked: total > 0 && total === checked,
};
}