markdown-task-checker
Version:
A CLI tool to check markdown task list completion
22 lines (18 loc) • 474 B
text/typescript
export interface TaskStats {
total: number;
checked: number;
allChecked: boolean;
}
export function parseMarkdownTasks(content: string): TaskStats {
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,
};
}