Add test for list item leading whitespace trimming

This commit is contained in:
thebabalola
2026-04-13 23:07:39 +01:00
parent 02c7f9bec0
commit 1e02a2b10b
@@ -377,3 +377,24 @@ fn test_codeblock_trailing_whitespace() {
assert_eq!(t, MdTree::CodeBlock { txt: "code\n```abc\nrest", lang: Some("rust") });
assert_eq!(r, b"");
}
#[test]
fn test_list_item_leading_whitespace() {
// extra spaces after marker
let buf = "- hello";
let (t, r) = parse_unordered_li(buf.as_bytes());
assert_eq!(t, MdTree::UnorderedListItem(vec![MdTree::PlainText("hello")].into()));
assert_eq!(r, b"");
// tab after the marker space
let buf = "- \thello";
let (t, r) = parse_unordered_li(buf.as_bytes());
assert_eq!(t, MdTree::UnorderedListItem(vec![MdTree::PlainText("hello")].into()));
assert_eq!(r, b"");
// ordered list
let buf = "1. hello";
let (t, r) = parse_ordered_li(buf.as_bytes());
assert_eq!(t, MdTree::OrderedListItem(1, vec![MdTree::PlainText("hello")].into()));
assert_eq!(r, b"");
}