( markdown: string, taskIndex: number, text: string )
| 221 | * `text` (verbatim — the caller owns any `due:`/`!priority` tokens). Used by |
| 222 | * inline task editing. */ |
| 223 | export function setTaskTextAtIndex( |
| 224 | markdown: string, |
| 225 | taskIndex: number, |
| 226 | text: string |
| 227 | ): string { |
| 228 | return editTaskAtIndex(markdown, taskIndex, (match) => { |
| 229 | const prefix = match[1] |
| 230 | const checkChar = match[2] |
| 231 | const tailWithBracket = match[3] |
| 232 | if (!tailWithBracket.startsWith(']')) return null |
| 233 | const trimmed = text.trim() |
| 234 | return `${prefix}${checkChar}]${trimmed ? ` ${trimmed}` : ''}` |
| 235 | }) |
| 236 | } |
| 237 | |
| 238 | /** Remove the task line at `taskIndex` and return both the removed line and the |
| 239 | * remaining body. `line` is null when the index is out of range. Fence-aware, |
no test coverage detected