5 releases
0.2.0 | Aug 3, 2023 |
---|---|
0.1.3 | Jun 21, 2023 |
0.1.2 | Jun 21, 2023 |
0.1.1 | Jun 21, 2023 |
0.1.0 | Jun 21, 2023 |
#1636 in Text processing
274 downloads per month
Used in markdown-it-gfm
8KB
108 lines
markdown-it-tasklist
A markdown-it.rs plugin to process GFM tasklists.
- [x] foo
- [ ] bar
Usage
To load the plugin:
let parser = &mut markdown_it::MarkdownIt::new();
markdown_it::plugins::cmark::add(parser);
markdown_it_tasklist::add(parser);
// or with checkboxes disabled
// markdown_it_tasklist::add_disabled(parser);
let ast = parser.parse("- [x] foo");
let html = ast.render();
lib.rs
:
A [markdown_it] plugin for parsing tasklists
let parser = &mut markdown_it::MarkdownIt::new();
markdown_it::plugins::cmark::add(parser);
markdown_it_tasklist::add(parser);
let root = parser.parse("- [x] task");
let mut names = vec![];
root.walk(|node,_| { names.push(node.name()); });
assert_eq!(names, vec![
"markdown_it::parser::core::root::Root",
"markdown_it::plugins::cmark::block::list::BulletList",
"markdown_it::plugins::cmark::block::list::ListItem",
"markdown_it_tasklist::TodoCheckbox",
"markdown_it::parser::inline::builtin::skip_text::Text",
]);
Dependencies
~5–14MB
~193K SLoC