|
1 | 1 | use std::cell::RefCell;
|
2 | 2 |
|
3 |
| -use self::nodes::{Ast, LineColumn}; |
| 3 | +use self::nodes::{Ast, LineColumn, ListType, NodeList}; |
4 | 4 |
|
5 | 5 | use super::*;
|
6 | 6 | use ntest::test_case;
|
@@ -41,6 +41,33 @@ fn commonmark_avoids_spurious_backslash() {
|
41 | 41 | );
|
42 | 42 | }
|
43 | 43 |
|
| 44 | +#[test] |
| 45 | +fn commonmark_renders_single_list_item() { |
| 46 | + let arena = Arena::new(); |
| 47 | + let options = Options::default(); |
| 48 | + let empty = LineColumn { line: 0, column: 0 }; |
| 49 | + let ast = |val: NodeValue| arena.alloc(AstNode::new(RefCell::new(Ast::new(val, empty)))); |
| 50 | + let list_options = NodeList { |
| 51 | + list_type: ListType::Ordered, |
| 52 | + start: 1, |
| 53 | + ..Default::default() |
| 54 | + }; |
| 55 | + let list = ast(NodeValue::List(list_options)); |
| 56 | + let item = ast(NodeValue::Item(list_options)); |
| 57 | + let p = ast(NodeValue::Paragraph); |
| 58 | + p.append(ast(NodeValue::Text("Item 1".to_owned()))); |
| 59 | + item.append(p); |
| 60 | + list.append(item); |
| 61 | + let mut output = vec![]; |
| 62 | + cm::format_document(item, &options, &mut output).unwrap(); |
| 63 | + compare_strs( |
| 64 | + &String::from_utf8(output).unwrap(), |
| 65 | + "1. Item 1\n", |
| 66 | + "rendered", |
| 67 | + "<synthetic>", |
| 68 | + ); |
| 69 | +} |
| 70 | + |
44 | 71 | #[test_case("$$x^2$$ and $1 + 2$ and $`y^2`$", "$$x^2$$ and $1 + 2$ and $`y^2`$\n")]
|
45 | 72 | #[test_case("$$\nx^2\n$$", "$$\nx^2\n$$\n")]
|
46 | 73 | #[test_case("```math\nx^2\n```", "``` math\nx^2\n```\n")]
|
|
0 commit comments