feat: 任务解析器及测试

This commit is contained in:
2026-06-08 17:18:06 +08:00
parent 9cdf5302be
commit ca7a86e888
2 changed files with 70 additions and 0 deletions

16
src/core/task-parser.ts Normal file
View File

@@ -0,0 +1,16 @@
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;
}