(md)
| 159 | // Parse GitHub-style task list items: "- [ ] ...", "- [x] ...", "- [/] ...". |
| 160 | // Each item also carries the nearest preceding heading as its `section`. |
| 161 | function parseChecklist(md) { |
| 162 | const items = []; |
| 163 | let section = null; |
| 164 | for (const line of md.split(/\r?\n/)) { |
| 165 | const h = line.match(/^\s*#{1,6}\s+(.*\S)\s*$/); |
| 166 | if (h) { section = stripMd(h[1]); continue; } |
| 167 | const m = line.match(/^\s*[-*]\s+\[([ xX/~\-])\]\s+(.*\S)\s*$/); |
| 168 | if (!m) continue; |
| 169 | const mark = m[1].toLowerCase(); |
| 170 | let status = "pending"; |
| 171 | if (mark === "x") status = "done"; |
| 172 | else if (mark === "/" || mark === "~" || mark === "-") status = "in_progress"; |
| 173 | const inline = statusFromText(m[2]); |
| 174 | if (inline) status = inline; |
| 175 | items.push({ title: stripMd(m[2]), status, section }); |
| 176 | } |
| 177 | return items; |
| 178 | } |
| 179 | |
| 180 | // Fallbacks when there are no checkbox items: numbered steps, then H2/H3 headings. |
| 181 | function parseLooseSteps(md) { |
no test coverage detected