aboutsummaryrefslogtreecommitdiffstats
path: root/tests/gfm_task_list_item.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-09-26 16:12:25 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-09-26 16:12:25 +0200
commita0c84c505d733be2e987a333a34244c1befb56cb (patch)
tree0545a747b6f2f627a71bd31949ad622bbc56c176 /tests/gfm_task_list_item.rs
parent9cb9e37c33173c16cbafd345f43e43b5a550537d (diff)
downloadmarkdown-rs-a0c84c505d733be2e987a333a34244c1befb56cb.tar.gz
markdown-rs-a0c84c505d733be2e987a333a34244c1befb56cb.tar.bz2
markdown-rs-a0c84c505d733be2e987a333a34244c1befb56cb.zip
Add support for compiling to mdast
See: <https://github.com/syntax-tree/mdast>.
Diffstat (limited to 'tests/gfm_task_list_item.rs')
-rw-r--r--tests/gfm_task_list_item.rs57
1 files changed, 56 insertions, 1 deletions
diff --git a/tests/gfm_task_list_item.rs b/tests/gfm_task_list_item.rs
index b824730..ae6c548 100644
--- a/tests/gfm_task_list_item.rs
+++ b/tests/gfm_task_list_item.rs
@@ -1,5 +1,8 @@
extern crate micromark;
-use micromark::{micromark, micromark_with_options, Constructs, Options};
+use micromark::{
+ mdast::{List, ListItem, Node, Paragraph, Position, Root, Text},
+ micromark, micromark_to_mdast, micromark_with_options, Constructs, Options,
+};
use pretty_assertions::assert_eq;
#[test]
@@ -240,5 +243,57 @@ Text.</li>
"should handle things like GitHub"
);
+ assert_eq!(
+ micromark_to_mdast("* [x] a\n* [ ] b\n* c", &gfm)?,
+ Node::Root(Root {
+ children: vec![Node::List(List {
+ ordered: false,
+ spread: false,
+ start: None,
+ children: vec![
+ Node::ListItem(ListItem {
+ checked: Some(true),
+ spread: false,
+ children: vec![Node::Paragraph(Paragraph {
+ children: vec![Node::Text(Text {
+ value: "a".to_string(),
+ position: Some(Position::new(1, 7, 6, 1, 8, 7))
+ }),],
+ position: Some(Position::new(1, 7, 6, 1, 8, 7))
+ })],
+ position: Some(Position::new(1, 1, 0, 1, 8, 7))
+ }),
+ Node::ListItem(ListItem {
+ checked: Some(false),
+ spread: false,
+ children: vec![Node::Paragraph(Paragraph {
+ children: vec![Node::Text(Text {
+ value: "b".to_string(),
+ position: Some(Position::new(2, 7, 14, 2, 8, 15))
+ }),],
+ position: Some(Position::new(2, 7, 14, 2, 8, 15))
+ })],
+ position: Some(Position::new(2, 1, 8, 2, 8, 15))
+ }),
+ Node::ListItem(ListItem {
+ checked: None,
+ spread: false,
+ children: vec![Node::Paragraph(Paragraph {
+ children: vec![Node::Text(Text {
+ value: "c".to_string(),
+ position: Some(Position::new(3, 3, 18, 3, 4, 19))
+ }),],
+ position: Some(Position::new(3, 3, 18, 3, 4, 19))
+ })],
+ position: Some(Position::new(3, 1, 16, 3, 4, 19))
+ }),
+ ],
+ position: Some(Position::new(1, 1, 0, 3, 4, 19))
+ })],
+ position: Some(Position::new(1, 1, 0, 3, 4, 19))
+ }),
+ "should support task list items as `checked` fields on `ListItem`s in mdast"
+ );
+
Ok(())
}