wayver's git archive


an obsidian renderer
git clone https://git.wayver.dev/sable

sable-markdown/src/parser/blocks/tests/paragraph.rs@337ba67f65eaa17b44e371af7c0f0c761d6aa914

raw
Date Commit Message Author Files + -
2026-02-23 01:55 initial mvp wayverd 139 17808 0
...

1use crate::{ast::*, parser::parse_markdown};
2
3#[test]
4fn minimal_paragraph() {
5    let doc = parse_markdown("a").unwrap();
6    assert_eq!(
7        doc,
8        Document {
9            blocks: vec![Block::Paragraph(vec![Inline::Text("a".to_string())])]
10        }
11    );
12
13    let doc = parse_markdown("a b c").unwrap();
14    assert_eq!(
15        doc,
16        Document {
17            blocks: vec![Block::Paragraph(vec![Inline::Text("a b c".to_string())])]
18        }
19    );
20
21    let doc = parse_markdown("a\nb\nc").unwrap();
22    assert_eq!(
23        doc,
24        Document {
25            blocks: vec![Block::Paragraph(vec![Inline::Text("a\nb\nc".to_string())])]
26        }
27    );
28}
29
30#[test]
31fn multi_paragraph1() {
32    let doc = parse_markdown("a\n\nb").unwrap();
33    assert_eq!(
34        doc,
35        Document {
36            blocks: vec![
37                Block::Paragraph(vec![Inline::Text("a".to_string())]),
38                Block::Paragraph(vec![Inline::Text("b".to_string())]),
39            ]
40        }
41    );
42}
43
44#[test]
45fn multi_paragraph2() {
46    let doc = parse_markdown("a\n\n\n\n\nb").unwrap();
47    assert_eq!(
48        doc,
49        Document {
50            blocks: vec![
51                Block::Paragraph(vec![Inline::Text("a".to_string())]),
52                Block::Paragraph(vec![Inline::Text("b".to_string())]),
53            ]
54        }
55    );
56}
57
58#[test]
59fn multi_paragraph3() {
60    let doc = parse_markdown("a\n\n  b").unwrap();
61    assert_eq!(
62        doc,
63        Document {
64            blocks: vec![
65                Block::Paragraph(vec![Inline::Text("a".to_string())]),
66                Block::Paragraph(vec![Inline::Text("b".to_string())]),
67            ]
68        }
69    );
70}
71
72#[test]
73fn multi_paragraph4() {
74    let doc = parse_markdown("aaa\n\n===").unwrap();
75    assert_eq!(
76        doc,
77        Document {
78            blocks: vec![
79                Block::Paragraph(vec![Inline::Text("aaa".to_string())]),
80                Block::Paragraph(vec![Inline::Text("===".to_string())]),
81            ]
82        }
83    );
84}
85
86#[test]
87fn paragraph_with_indented_line1() {
88    let doc = parse_markdown("a\n    b").unwrap();
89    assert_eq!(
90        doc,
91        Document {
92            blocks: vec![Block::Paragraph(vec![Inline::Text("a\n b".to_string())])],
93        }
94    );
95}
96