lossendae / commonmark-task-lists
0.2.0
2015-09-21 20:34 UTC
Requires
- php: >=5.4
- league/commonmark: 0.11.*
This package is not auto-updated.
Last update: 2022-02-01 12:51:27 UTC
README
此项目已过时,请使用phpleague提供的扩展:league/commonmark的GFM风格任务列表扩展
将GitHub风格的任务列表实现为phpleague/commonmark:https://help.github.com/articles/writing-on-github/#task-lists)
安装
此项目可以通过Composer安装
composer require lossendae/commonmark-task-lists
使用方法
use League\CommonMark\Converter; use League\CommonMark\DocParser; use League\CommonMark\Environment; use League\CommonMark\HtmlRenderer; use Lossendae\CommonMark\TaskLists\TaskListsParser; use Lossendae\CommonMark\TaskLists\TaskListsCheckboxRenderer; $environment = Environment::createCommonMarkEnvironment(); $environment->addInlineRenderer('Lossendae\CommonMark\TaskLists\TaskListsCheckbox', new TaskListsCheckboxRenderer()); $environment->addInlineParser(new TaskListsParser()); $converter = new Converter(new DocParser($environment), new HtmlRenderer($environment)); echo $converter->convertToHtml('# Hello World!');
语法
列表可以通过在列表项前加[ ]或[x](分别表示未完成或已完成)转换为任务列表。
- [x] @mentions, #refs, [links](), **formatting**, and <del>tags</del> are supported
- [x] list syntax is required (any unordered or ordered list supported)
- [x] this is a complete item
- [ ] this is an incomplete item
任务列表在通过CommonMark解析后将以复选框形式呈现。选择或取消选择这些复选框,以在您的文档中标记为完成或未完成。
任务列表可以进行嵌套以更好地组织您的任务
- [ ] a bigger project
- [ ] first subtask #1234
- [ ] follow up subtask #4321
- [ ] final subtask cc @mention
- [ ] a separate task
任务列表可以嵌套到任意深度,尽管我们建议嵌套不超过一次或两次;更复杂的工作应该拆分为单独的列表。