aboutsummaryrefslogtreecommitdiffstats
path: root/tests/thematic_break.rs
blob: 02be90f9b36d97e5aba3a6e1a2668d4ae228cf96 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
extern crate micromark;
use micromark::micromark;

#[test]
fn thematic_break() {
    assert_eq!(
        micromark("***\n---\n___"),
        "<hr />\n<hr />\n<hr />",
        "should support thematic breaks w/ asterisks, dashes, and underscores"
    );

    assert_eq!(
        micromark("+++"),
        "<p>+++</p>",
        "should not support thematic breaks w/ plusses"
    );

    assert_eq!(
        micromark("==="),
        "<p>===</p>",
        "should not support thematic breaks w/ equals"
    );

    assert_eq!(
        micromark("--"),
        "<p>--</p>",
        "should not support thematic breaks w/ two dashes"
    );

    assert_eq!(
        micromark("**"),
        "<p>**</p>",
        "should not support thematic breaks w/ two asterisks"
    );

    assert_eq!(
        micromark("__"),
        "<p>__</p>",
        "should not support thematic breaks w/ two underscores"
    );

    assert_eq!(
        micromark(" ***"),
        "<hr />",
        "should support thematic breaks w/ 1 space"
    );

    assert_eq!(
        micromark("  ***"),
        "<hr />",
        "should support thematic breaks w/ 2 spaces"
    );

    assert_eq!(
        micromark("   ***"),
        "<hr />",
        "should support thematic breaks w/ 3 spaces"
    );

    assert_eq!(
        micromark("    ***"),
        "<pre><code>***\n</code></pre>",
        "should not support thematic breaks w/ 4 spaces"
    );

    assert_eq!(
        micromark("Foo\n    ***"),
        "<p>Foo\n***</p>",
        "should not support thematic breaks w/ 4 spaces as paragraph continuation"
    );

    assert_eq!(
        micromark("_____________________________________"),
        "<hr />",
        "should support thematic breaks w/ many markers"
    );

    // To do: list (should prefer thematic break).
    // assert_eq!(
    //     micromark(" - - -"),
    //     "<hr />",
    //     "should support thematic breaks w/ spaces (1)"
    // );

    assert_eq!(
        micromark(" **  * ** * ** * **"),
        "<hr />",
        "should support thematic breaks w/ spaces (2)"
    );

    // To do: list (prefer thematic break).
    // assert_eq!(
    //     micromark("-     -      -      -"),
    //     "<hr />",
    //     "should support thematic breaks w/ spaces (3)"
    // );

    // To do: list (prefer thematic break).
    // assert_eq!(
    //     micromark("- - - -    "),
    //     "<hr />",
    //     "should support thematic breaks w/ trailing spaces"
    // );

    assert_eq!(
        micromark("_ _ _ _ a"),
        "<p>_ _ _ _ a</p>",
        "should not support thematic breaks w/ other characters (1)"
    );

    assert_eq!(
        micromark("a------"),
        "<p>a------</p>",
        "should not support thematic breaks w/ other characters (2)"
    );

    assert_eq!(
        micromark("---a---"),
        "<p>---a---</p>",
        "should not support thematic breaks w/ other characters (3)"
    );

    assert_eq!(
        micromark(" *-*"),
        "<p><em>-</em></p>",
        "should not support thematic breaks w/ mixed markers"
    );

    assert_eq!(
        micromark("- foo\n***\n- bar"),
        "<ul>\n<li>foo</li>\n</ul>\n<hr />\n<ul>\n<li>bar</li>\n</ul>",
        "should support thematic breaks mixed w/ lists (1)"
    );

    // To do: list (prefer thematic break).
    // assert_eq!(
    //     micromark("* Foo\n* * *\n* Bar"),
    //     "<ul>\n<li>Foo</li>\n</ul>\n<hr />\n<ul>\n<li>Bar</li>\n</ul>",
    //     "should support thematic breaks mixed w/ lists (2)"
    // );

    assert_eq!(
        micromark("Foo\n***\nbar"),
        "<p>Foo</p>\n<hr />\n<p>bar</p>",
        "should support thematic breaks interrupting paragraphs"
    );

    assert_eq!(
        micromark("Foo\n---\nbar"),
        "<h2>Foo</h2>\n<p>bar</p>",
        "should not support thematic breaks w/ dashes interrupting paragraphs (setext heading)"
    );

    // To do: list (prefer thematic break).
    // assert_eq!(
    //     micromark("- Foo\n- * * *"),
    //     "<ul>\n<li>Foo</li>\n<li>\n<hr />\n</li>\n</ul>",
    //     "should support thematic breaks in lists"
    // );

    assert_eq!(
        micromark("> ---\na"),
        "<blockquote>\n<hr />\n</blockquote>\n<p>a</p>",
        "should not support lazyness (1)"
    );

    assert_eq!(
        micromark("> a\n---"),
        "<blockquote>\n<p>a</p>\n</blockquote>\n<hr />",
        "should not support lazyness (2)"
    );

    // To do: turning things off.
    // assert_eq!(
    //   micromark("***", {extensions: [{disable: {null: ["thematicBreak"]}}]}),
    //   "<p>***</p>",
    //   "should support turning off thematic breaks"
    // );
}