Markdown interchange

A task travels as a markdown document: a small front-matter block carrying the id, number, and tags, then the title as a heading and the body. That is what a card becomes when you drag it to the desktop, and what a dropped .md, text, or HTML turns back into. Plain text with no front matter is fine — the first line (or first heading) is the title, the rest the body.

import { taskToMarkdown, markdownToTask } from 'tosijs-virta'

const md = taskToMarkdown({ id: 'abc', num: 38, title: 'Ship it', body: 'Soon.', tags: ['status:doing', 'project:me'] })
const back = markdownToTask(md)
preview.textContent = md + '\n---parsed---\n' + JSON.stringify(back)
test('round-trips id, number, title, tags, and body', () => {
  expect(preview.textContent).toContain('"id":"abc"')
  expect(preview.textContent).toContain('"num":38')
  expect(preview.textContent).toContain('"title":"Ship it"')
  expect(preview.textContent).toContain('"tags":["status:doing","project:me"]')
  expect(preview.textContent).toContain('"body":"Soon."')
})