From a0c84c505d733be2e987a333a34244c1befb56cb Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 26 Sep 2022 16:12:25 +0200 Subject: Add support for compiling to mdast See: . --- tests/gfm_task_list_item.rs | 57 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) (limited to 'tests/gfm_task_list_item.rs') 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. "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(()) } -- cgit