@hackmd/markdown-it-task-lists

中文文档
2.1.4发布于 2024/03/27ISCCommonJS零依赖近 30 天下载 1.7万

A markdown-it plugin to create GitHub-style task lists

原始使用文档
文档目录7 节
  1. What it does
  2. Why is this useful?
  3. Installation
  4. Usage
  5. Browser Usage
  6. Tests
  7. License

markdown-it-task-lists

A markdown-it plugin to create GitHub-style task lists

Greenkeeper badge Build Status Code Climate

What it does

  • Builds task/todo lists out of markdown lists with items starting with [ ] or [x].
  • Nothing else

Why is this useful?

When you have markdown documentation with checklists, rendering HTML checkboxes out of the list items looks nicer than the raw square brackets.

Installation

npm install markdown-it-task-lists

Usage

Use it the same as a normal markdown-it plugin:

var md = require('markdown-it');
var taskLists = require('markdown-it-task-lists');

var parser = md().use(taskLists);

var result = parser.render(...); // markdown string containing task list items

The rendered checkboxes are disabled; to change this, pass a truthy value into the enabled property of the plugin options:

var parser = md().use(taskLists, {enabled: true});

If you'd like to wrap the rendered list items in a <label> element for UX purposes, pass a truthy value to the label property of the plugin options:

var parser = md().use(taskLists, {label: true});

To add the label after the checkbox pass a truthy value to labelAfter property:

var parser = md().use(taskLists, {label: true, labelAfter: true});

Note: This option does require the label option to be truthy.

The options can be combined, of course.

Browser Usage

If you use one of the versions of this module available in dist/ directly in a browser by including it with a <script> element, it will be available globally in window.markdownitTaskLists.

Tests

npm install
npm test

License

ISC

版本与发布记录

@hackmd/markdown-it-task-lists 共发布 4 个版本,首次发布于 2020/05/13;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.1.4latest2024/03/272 年前
2.1.32024/01/242 年前
2.1.22024/01/242 年前
2.1.12020/05/136 年前

关于 @hackmd/markdown-it-task-lists 的常见问题

@hackmd/markdown-it-task-lists 是什么?

A markdown-it plugin to create GitHub-style task lists

如何安装 @hackmd/markdown-it-task-lists?

在项目目录运行 npm install @hackmd/markdown-it-task-lists,或使用 pnpm add / yarn add / bun add。

@hackmd/markdown-it-task-lists 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/hackmd__markdown-it-task-lists 是否存在。

@hackmd/markdown-it-task-lists 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@hackmd/markdown-it-task-lists 可以商用吗?

@hackmd/markdown-it-task-lists 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@hackmd/markdown-it-task-lists 的下载量有多少?

根据 npm 官方下载统计,@hackmd/markdown-it-task-lists 在 2026/10/17 – 2026/11/15 这 30 天内被下载 17,001 次,日均约 567 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@hackmd/markdown-it-task-lists 还在维护吗?

最新版本 2.1.4 发布于 2024/03/27(2 年前);至今共发布 4 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/05/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。