diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-10-29 14:03:59 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-11-25 11:21:15 +0100 |
commit | 4f776347163a514abadc7ded95e66a459be03bc9 (patch) | |
tree | a518ece6a62c939b3c468f2947e82e608300b664 /tests/gfm_task_list_item.rs | |
parent | d5ae7bb13fdb5e855c678ced9b66d26674e08136 (diff) | |
download | markdown-rs-4f776347163a514abadc7ded95e66a459be03bc9.tar.gz markdown-rs-4f776347163a514abadc7ded95e66a459be03bc9.tar.bz2 markdown-rs-4f776347163a514abadc7ded95e66a459be03bc9.zip |
Fix GFM task list checkboxes followed by eol
Closes GH-24.
Diffstat (limited to 'tests/gfm_task_list_item.rs')
-rw-r--r-- | tests/gfm_task_list_item.rs | 60 |
1 files changed, 59 insertions, 1 deletions
diff --git a/tests/gfm_task_list_item.rs b/tests/gfm_task_list_item.rs index 638206f..8b3f066 100644 --- a/tests/gfm_task_list_item.rs +++ b/tests/gfm_task_list_item.rs @@ -1,5 +1,5 @@ use markdown::{ - mdast::{List, ListItem, Node, Paragraph, Root, Text}, + mdast::{Emphasis, List, ListItem, Node, Paragraph, Root, Text}, to_html, to_html_with_options, to_mdast, unist::Position, Options, ParseOptions, @@ -291,5 +291,63 @@ Text.</li> "should support task list items as `checked` fields on `ListItem`s in mdast" ); + assert_eq!( + to_mdast( + "* [x]\r\n a\n* [ ] b\n* [x]\t \r*c*", + &ParseOptions::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".into(), + position: Some(Position::new(2, 1, 7, 2, 4, 10)) + }),], + position: Some(Position::new(2, 1, 7, 2, 4, 10)) + })], + position: Some(Position::new(1, 1, 0, 2, 4, 10)) + }), + Node::ListItem(ListItem { + checked: Some(false), + spread: false, + children: vec![Node::Paragraph(Paragraph { + children: vec![Node::Text(Text { + value: " b".into(), + position: Some(Position::new(3, 7, 17, 3, 10, 20)) + }),], + position: Some(Position::new(3, 7, 17, 3, 10, 20)) + })], + position: Some(Position::new(3, 1, 11, 3, 10, 20)) + }), + Node::ListItem(ListItem { + checked: Some(true), + spread: false, + children: vec![Node::Paragraph(Paragraph { + children: vec![Node::Emphasis(Emphasis { + children: vec![Node::Text(Text { + value: "c".into(), + position: Some(Position::new(5, 2, 30, 5, 3, 31)) + }),], + position: Some(Position::new(5, 1, 29, 5, 4, 32)) + })], + position: Some(Position::new(5, 1, 29, 5, 4, 32)) + })], + position: Some(Position::new(4, 1, 21, 5, 4, 32)) + }), + ], + position: Some(Position::new(1, 1, 0, 5, 4, 32)) + })], + position: Some(Position::new(1, 1, 0, 5, 4, 32)) + }), + "should handle lots of whitespace after checkbox, and non-text" + ); + Ok(()) } |