diff options
-rw-r--r-- | Untitled.txt | 1 | ||||
-rw-r--r-- | src/to_mdast.rs | 4 | ||||
-rw-r--r-- | tests/list.rs | 42 |
3 files changed, 32 insertions, 15 deletions
diff --git a/Untitled.txt b/Untitled.txt index 90e2f5e..fb1e53c 100644 --- a/Untitled.txt +++ b/Untitled.txt @@ -6,6 +6,7 @@ micromark.js: `atLineEnding` in html (text) should always eat arbitrary whitespa ```rs // --------------------- // Useful helper: +extern crate std; use std::println; use alloc::string::String; diff --git a/src/to_mdast.rs b/src/to_mdast.rs index 4d2ca76..e76bad5 100644 --- a/src/to_mdast.rs +++ b/src/to_mdast.rs @@ -1430,7 +1430,9 @@ fn on_exit_list_item_value(context: &mut CompileContext) { if let Node::List(node) = context.tail_penultimate_mut() { debug_assert!(node.ordered, "expected list to be ordered"); - node.start = Some(start); + if node.start.is_none() { + node.start = Some(start); + } } else { unreachable!("expected list on stack"); } diff --git a/tests/list.rs b/tests/list.rs index e8c42e8..0c2992e 100644 --- a/tests/list.rs +++ b/tests/list.rs @@ -616,27 +616,41 @@ fn list() -> Result<(), String> { ); assert_eq!( - to_mdast("3. a", &Default::default())?, + to_mdast("3. a\n4. b", &Default::default())?, Node::Root(Root { children: vec![Node::List(List { ordered: true, spread: false, start: Some(3), - children: vec![Node::ListItem(ListItem { - checked: None, - spread: false, - children: vec![Node::Paragraph(Paragraph { - children: vec![Node::Text(Text { - value: "a".into(), + children: vec![ + Node::ListItem(ListItem { + checked: None, + spread: false, + children: vec![Node::Paragraph(Paragraph { + children: vec![Node::Text(Text { + value: "a".into(), + position: Some(Position::new(1, 4, 3, 1, 5, 4)) + }),], position: Some(Position::new(1, 4, 3, 1, 5, 4)) - }),], - position: Some(Position::new(1, 4, 3, 1, 5, 4)) - })], - position: Some(Position::new(1, 1, 0, 1, 5, 4)) - })], - position: Some(Position::new(1, 1, 0, 1, 5, 4)) + })], + position: Some(Position::new(1, 1, 0, 1, 5, 4)) + }), + Node::ListItem(ListItem { + checked: None, + spread: false, + children: vec![Node::Paragraph(Paragraph { + children: vec![Node::Text(Text { + value: "b".into(), + position: Some(Position::new(2, 4, 8, 2, 5, 9)) + }),], + position: Some(Position::new(2, 4, 8, 2, 5, 9)) + })], + position: Some(Position::new(2, 1, 5, 2, 5, 9)) + }) + ], + position: Some(Position::new(1, 1, 0, 2, 5, 9)) })], - position: Some(Position::new(1, 1, 0, 1, 5, 4)) + position: Some(Position::new(1, 1, 0, 2, 5, 9)) }), "should support `start` fields on `List` w/ `ordered: true` in mdast" ); |