MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / setTaskTextAtIndex

Function setTaskTextAtIndex

packages/shared-domain/src/tasklists.ts:223–236  ·  view source on GitHub ↗
(
  markdown: string,
  taskIndex: number,
  text: string
)

Source from the content-addressed store, hash-verified

221 * `text` (verbatim — the caller owns any `due:`/`!priority` tokens). Used by
222 * inline task editing. */
223export 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,

Callers 2

store.tsFile · 0.90
tasklists.test.tsFile · 0.90

Calls 1

editTaskAtIndexFunction · 0.85

Tested by

no test coverage detected