17 lines
395 B
TypeScript
17 lines
395 B
TypeScript
import type { TaskItem } from "../types.ts";
|
|
|
|
export function parseTasks(content: string): TaskItem[] {
|
|
const tasks: TaskItem[] = [];
|
|
const lines = content.split("\n");
|
|
for (const line of lines) {
|
|
const match = line.match(/^[\s]*- \[([ xX])\] (.*)$/);
|
|
if (match) {
|
|
tasks.push({
|
|
checked: match[1] !== " ",
|
|
text: match[2],
|
|
});
|
|
}
|
|
}
|
|
return tasks;
|
|
}
|