| 1 |
use super::*; |
| 2 |
|
| 3 |
#[test] |
| 4 |
fn block_directives() { |
| 5 |
html_opts!( |
| 6 |
[extension.block_directive], |
| 7 |
concat!( |
| 8 |
":::foo bar\n", |
| 9 |
"Paragraph 1\n", |
| 10 |
"\n", |
| 11 |
"Paragraph 2\n", |
| 12 |
":::\n" |
| 13 |
), |
| 14 |
concat!( |
| 15 |
"<div class=\"foo bar\">\n", |
| 16 |
"<p>Paragraph 1</p>\n", |
| 17 |
"<p>Paragraph 2</p>\n", |
| 18 |
"</div>\n", |
| 19 |
), |
| 20 |
); |
| 21 |
|
| 22 |
html_opts!( |
| 23 |
[extension.block_directive], |
| 24 |
concat!( |
| 25 |
"- item one\n", |
| 26 |
"\n", |
| 27 |
" :::foo bar\n", |
| 28 |
" Paragraph 1\n", |
| 29 |
"\n", |
| 30 |
" Paragraph 2\n", |
| 31 |
" :::\n", |
| 32 |
"- item two\n" |
| 33 |
), |
| 34 |
concat!( |
| 35 |
"<ul>\n", |
| 36 |
"<li>\n", |
| 37 |
"<p>item one</p>\n", |
| 38 |
"<div class=\"foo bar\">\n", |
| 39 |
"<p>Paragraph 1</p>\n", |
| 40 |
"<p>Paragraph 2</p>\n", |
| 41 |
"</div>\n", |
| 42 |
"</li>\n", |
| 43 |
"<li>\n", |
| 44 |
"<p>item two</p>\n", |
| 45 |
"</li>\n", |
| 46 |
"</ul>\n", |
| 47 |
), |
| 48 |
); |
| 49 |
} |
| 50 |
|
| 51 |
#[test] |
| 52 |
fn sourcepos() { |
| 53 |
assert_ast_match!( |
| 54 |
[extension.block_directive], |
| 55 |
"- item one\n" |
| 56 |
"\n" |
| 57 |
" :::foo bar\n" |
| 58 |
" Paragraph 1\n" |
| 59 |
" :::\n" |
| 60 |
"- item two\n", |
| 61 |
(document (1:1-6:10) [ |
| 62 |
(list (1:1-6:10) [ |
| 63 |
(item (1:1-5:5) [ |
| 64 |
(paragraph (1:3-1:10) [ |
| 65 |
(text (1:3-1:10) "item one") |
| 66 |
]) |
| 67 |
(block_directive (3:3-5:5) [ |
| 68 |
(paragraph (4:3-4:13) [ |
| 69 |
(text (4:3-4:13) "Paragraph 1") |
| 70 |
]) |
| 71 |
]) |
| 72 |
]) |
| 73 |
(item (6:1-6:10) [ |
| 74 |
(paragraph (6:3-6:10) [ |
| 75 |
(text (6:3-6:10) "item two") |
| 76 |
]) |
| 77 |
]) |
| 78 |
]) |
| 79 |
]) |
| 80 |
); |
| 81 |
} |
| 82 |
|
| 83 |
#[test] |
| 84 |
fn sourcepos_with_block_quote() { |
| 85 |
assert_ast_match!( |
| 86 |
[extension.block_directive], |
| 87 |
":::foo bar\n" |
| 88 |
"> a\n" |
| 89 |
":::\n", |
| 90 |
(document (1:1-3:3) [ |
| 91 |
(block_directive (1:1-3:3) [ |
| 92 |
(block_quote (2:1-2:3) [ |
| 93 |
(paragraph (2:3-2:3) [ |
| 94 |
(text (2:3-2:3) "a") |
| 95 |
]) |
| 96 |
]) |
| 97 |
]) |
| 98 |
]) |
| 99 |
); |
| 100 |
} |
| 101 |
|
| 102 |
#[test] |
| 103 |
fn sourcepos_with_list() { |
| 104 |
assert_ast_match!( |
| 105 |
[extension.block_directive], |
| 106 |
":::foo bar\n" |
| 107 |
"* a\n" |
| 108 |
":::\n", |
| 109 |
(document (1:1-3:3) [ |
| 110 |
(block_directive (1:1-3:3) [ |
| 111 |
(list (2:1-2:3) [ |
| 112 |
(item (2:1-2:3) [ |
| 113 |
(paragraph (2:3-2:3) [ |
| 114 |
(text (2:3-2:3) "a") |
| 115 |
]) |
| 116 |
]) |
| 117 |
]) |
| 118 |
]) |
| 119 |
]) |
| 120 |
); |
| 121 |
} |
| 122 |
|
| 123 |
#[test] |
| 124 |
fn sourcepos_in_blockquote() { |
| 125 |
assert_ast_match!( |
| 126 |
[extension.block_directive], |
| 127 |
"> :::foo bar\n" |
| 128 |
"> a\n" |
| 129 |
"> :::\n", |
| 130 |
(document (1:1-3:5) [ |
| 131 |
(block_quote (1:1-3:5) [ |
| 132 |
(block_directive (1:3-3:5) [ |
| 133 |
(paragraph (2:3-2:3) [ |
| 134 |
(text (2:3-2:3) "a") |
| 135 |
]) |
| 136 |
]) |
| 137 |
]) |
| 138 |
]) |
| 139 |
); |
| 140 |
} |