| 1 |
use super::*; |
| 2 |
|
| 3 |
#[test] |
| 4 |
fn greentext_preserved() { |
| 5 |
html_opts!( |
| 6 |
[extension.greentext, render.hardbreaks], |
| 7 |
">implying\n>>implying", |
| 8 |
"<p>>implying<br />\n>>implying</p>\n" |
| 9 |
); |
| 10 |
} |
| 11 |
|
| 12 |
#[test] |
| 13 |
fn empty_line() { |
| 14 |
html_opts!([extension.greentext], ">", "<p>></p>\n"); |
| 15 |
} |
| 16 |
|
| 17 |
#[test] |
| 18 |
fn separate_quotes_on_line_end() { |
| 19 |
html_opts!( |
| 20 |
[extension.greentext], |
| 21 |
"> 1\n>\n> 2", |
| 22 |
"<blockquote>\n<p>1</p>\n<p>2</p>\n</blockquote>\n" |
| 23 |
); |
| 24 |
} |
| 25 |
|
| 26 |
#[test] |
| 27 |
fn unnest_quotes_on_line_end() { |
| 28 |
html_opts!( |
| 29 |
[extension.greentext], |
| 30 |
"> 1\n> > 2\n> 1", |
| 31 |
"<blockquote>\n<p>1</p>\n<blockquote>\n<p>2</p>\n</blockquote>\n<p>1</p>\n</blockquote>\n" |
| 32 |
); |
| 33 |
} |
| 34 |
|
| 35 |
#[test] |
| 36 |
fn unnest_quotes_on_line_end_commonmark() { |
| 37 |
html_opts!( |
| 38 |
[extension.greentext], |
| 39 |
"> 1\n> > 2\n> \n> 1", |
| 40 |
"<blockquote>\n<p>1</p>\n<blockquote>\n<p>2</p>\n</blockquote>\n<p>1</p>\n</blockquote>\n" |
| 41 |
); |
| 42 |
} |
| 43 |
|
| 44 |
#[test] |
| 45 |
fn greentext_disabled_blockquote() { |
| 46 |
assert_ast_match!( |
| 47 |
[], |
| 48 |
"> First line.\n> The second sentence in the first line.\n>\n> Second line.", |
| 49 |
(document (1:1-4:14) [ |
| 50 |
(block_quote (1:1-4:14) [ |
| 51 |
(paragraph (1:3-2:40) [ |
| 52 |
(text (1:3-1:13) "First line.") |
| 53 |
(softbreak (1:14-1:14)) |
| 54 |
(text (2:3-2:40) "The second sentence in the first line.") |
| 55 |
]) |
| 56 |
(paragraph (4:3-4:14) [ |
| 57 |
(text (4:3-4:14) "Second line.") |
| 58 |
]) |
| 59 |
]) |
| 60 |
]) |
| 61 |
); |
| 62 |
} |
| 63 |
|
| 64 |
#[test] |
| 65 |
fn greentext_enabled_blockquote() { |
| 66 |
assert_ast_match!( |
| 67 |
[extension.greentext], |
| 68 |
"> First line.\n> The second sentence in the first line.\n>\n> Second line.", |
| 69 |
(document (1:1-4:14) [ |
| 70 |
(block_quote (1:1-4:14) [ |
| 71 |
(paragraph (1:3-2:40) [ |
| 72 |
(text (1:3-1:13) "First line.") |
| 73 |
(softbreak (1:14-1:14)) |
| 74 |
(text (2:3-2:40) "The second sentence in the first line.") |
| 75 |
]) |
| 76 |
(paragraph (4:3-4:14) [ |
| 77 |
(text (4:3-4:14) "Second line.") |
| 78 |
]) |
| 79 |
]) |
| 80 |
]) |
| 81 |
); |
| 82 |
} |
| 83 |
|
| 84 |
#[test] |
| 85 |
fn greentext_disabled_blockquote_alerts() { |
| 86 |
html_opts!( |
| 87 |
[extension.alerts], |
| 88 |
"> [!Note]\n> This is the first line.\n>\n> Second line.", |
| 89 |
concat!( |
| 90 |
"<div class=\"markdown-alert markdown-alert-note\">\n", |
| 91 |
"<p class=\"markdown-alert-title\">Note</p>\n", |
| 92 |
"<p>This is the first line.</p>\n", |
| 93 |
"<p>Second line.</p>\n", |
| 94 |
"</div>\n", |
| 95 |
), |
| 96 |
); |
| 97 |
} |
| 98 |
|
| 99 |
#[test] |
| 100 |
fn greentext_enabled_blockquote_alerts() { |
| 101 |
html_opts!( |
| 102 |
[extension.greentext, extension.alerts], |
| 103 |
"> [!Note]\n> This is the first line.\n>\n> Second line.", |
| 104 |
concat!( |
| 105 |
"<div class=\"markdown-alert markdown-alert-note\">\n", |
| 106 |
"<p class=\"markdown-alert-title\">Note</p>\n", |
| 107 |
"<p>This is the first line.</p>\n", |
| 108 |
"<p>Second line.</p>\n", |
| 109 |
"</div>\n", |
| 110 |
), |
| 111 |
); |
| 112 |
} |