wayver's git archive


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

sable-markdown/src/parser/inline/tests/emphasis.rs@2b84405277e54ab809e328cf0237374d4b4dbd0c

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 emphasis1() {
5    let doc = parse_markdown("*foo bar*").unwrap();
6    assert_eq!(
7        doc,
8        Document {
9            blocks: vec![Block::Paragraph(vec![Inline::Emphasis(vec![
10                Inline::Text("foo bar".to_string())
11            ])])],
12        }
13    );
14}
15
16#[test]
17fn emphasis2() {
18    let doc = parse_markdown("* a *").unwrap();
19    assert_eq!(
20        doc,
21        Document {
22            blocks: vec![Block::List(List {
23                kind: ListKind::Bullet(ListBulletKind::Star),
24                items: vec![ListItem {
25                    task: None,
26                    blocks: vec![Block::Paragraph(vec![Inline::Text("a *".to_owned())])]
27                }]
28            })]
29        }
30    );
31}
32
33#[test]
34fn emphasis3() {
35    let doc = parse_markdown("foo ___bar___").unwrap();
36    assert_eq!(
37        doc,
38        Document {
39            blocks: vec![Block::Paragraph(vec![
40                Inline::Text("foo ".to_owned()),
41                Inline::Strong(vec![Inline::Emphasis(vec![Inline::Text("bar".to_owned())])])
42            ])]
43        }
44    );
45}
46
47#[test]
48fn emphasis4() {
49    let doc = parse_markdown("**foo ___bar___ baz**").unwrap();
50    assert_eq!(
51        doc,
52        Document {
53            blocks: vec![Block::Paragraph(vec![Inline::Strong(vec![
54                Inline::Text("foo ".to_owned()),
55                Inline::Strong(vec![Inline::Emphasis(vec![Inline::Text("bar".to_owned())])]),
56                Inline::Text(" baz".to_owned())
57            ])])]
58        }
59    );
60}
61