(markdown: string)
| 285 | * [x] completed item |
| 286 | */ |
| 287 | export function parseMarkdownChecklist(markdown: string): TodoItem[] { |
| 288 | const lines = markdown.split("\n") |
| 289 | const todos: TodoItem[] = [] |
| 290 | |
| 291 | for (let i = 0; i < lines.length; i++) { |
| 292 | const line = lines[i] |
| 293 | |
| 294 | if (!line) { |
| 295 | continue |
| 296 | } |
| 297 | |
| 298 | const trimmedLine = line.trim() |
| 299 | |
| 300 | if (!trimmedLine) { |
| 301 | continue |
| 302 | } |
| 303 | |
| 304 | // Match markdown checkbox patterns |
| 305 | const checkboxMatch = trimmedLine.match(/^\[([x\-\s])\]\s*(.+)$/i) |
| 306 | |
| 307 | if (checkboxMatch) { |
| 308 | const statusChar = checkboxMatch[1] ?? " " |
| 309 | const content = checkboxMatch[2] ?? "" |
| 310 | let status: TodoItem["status"] = "pending" |
| 311 | |
| 312 | if (statusChar.toLowerCase() === "x") { |
| 313 | status = "completed" |
| 314 | } else if (statusChar === "-") { |
| 315 | status = "in_progress" |
| 316 | } |
| 317 | |
| 318 | todos.push({ id: `todo-${i}`, content: content.trim(), status }) |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | return todos |
| 323 | } |
no outgoing calls
no test coverage detected