Built-in

Task List

Plugin for rendering interactive checkboxes from GitHub-style task list syntax.

The comark/plugins/task-list plugin converts GitHub-style task list syntax into interactive checkboxes. It runs before inline parsing to prevent Comark from misinterpreting [ ] and [x] as component syntax.

Usage

import { parse } from 'comark'
import taskList from 'comark/plugins/task-list'

const result = await parse(`
- [x] Write the docs
- [ ] Fix the bug
- [x] Ship it
`, {
  plugins: [taskList()]
})

With framework components:

<script setup lang="ts">
import { Comark } from '@comark/vue'
import taskList from '@comark/vue/plugins/task-list'
</script>

<template>
  <Comark :plugins="[taskList()]">{{ content }}</Comark>
</template>

Features

Syntax

Use [ ] for unchecked and [x] (or [X]) for checked items inside a list:

- [x] Completed task
- [ ] Pending task
- [X] Also completed (case-insensitive)

Task lists also work in nested lists:

- [x] Parent task
  - [x] Sub-task done
  - [ ] Sub-task pending
- [ ] Another parent task

CSS Classes

The plugin adds classes to help with styling:

ElementClass
<ul> containing taskscontains-task-list
<li> with a checkboxtask-list-item
<input> checkboxtask-list-item-checkbox
.task-list-item {
  list-style: none;
}

.task-list-item-checkbox {
  margin-right: 0.5em;
}

API

taskList()

Returns a ComarkPlugin that converts task list syntax to checkboxes. Takes no options.

Returns: ComarkPlugin