2019-06-26 18:53:50 +01:00
|
|
|
use orgize::Org;
|
2019-06-26 22:12:41 +01:00
|
|
|
use pretty_assertions::assert_eq;
|
2019-04-07 18:40:52 +01:00
|
|
|
|
2019-06-26 22:12:41 +01:00
|
|
|
macro_rules! test_suite {
|
2019-04-24 14:54:51 +01:00
|
|
|
($name:ident, $content:expr, $expected:expr) => {
|
|
|
|
#[test]
|
2019-07-31 08:09:01 +01:00
|
|
|
fn $name() {
|
2019-06-26 18:53:50 +01:00
|
|
|
let mut writer = Vec::new();
|
2019-06-27 06:20:21 +01:00
|
|
|
let org = Org::parse($content);
|
2019-10-28 08:02:56 +00:00
|
|
|
org.write_html(&mut writer).unwrap();
|
2019-06-26 18:53:50 +01:00
|
|
|
let string = String::from_utf8(writer).unwrap();
|
|
|
|
assert_eq!(string, $expected);
|
2019-04-24 14:54:51 +01:00
|
|
|
}
|
|
|
|
};
|
2019-04-07 18:40:52 +01:00
|
|
|
}
|
|
|
|
|
2019-06-26 22:12:41 +01:00
|
|
|
test_suite!(
|
2019-04-24 14:54:51 +01:00
|
|
|
emphasis,
|
2019-06-26 22:12:41 +01:00
|
|
|
"*bold*, /italic/,\n_underlined_, =verbatim= and ~code~",
|
|
|
|
"<main><section><p><b>bold</b>, <i>italic</i>,\n<u>underlined</u>, \
|
|
|
|
<code>verbatim</code> and <code>code</code></p></section></main>"
|
2019-05-18 14:34:29 +01:00
|
|
|
);
|
|
|
|
|
2019-10-06 04:42:44 +01:00
|
|
|
test_suite!(
|
|
|
|
link,
|
|
|
|
"Visit[[http://example.com][link1]]or[[http://example.com][link1]].",
|
|
|
|
r#"<main><section><p>Visit<a href="http://example.com">link1</a>or<a href="http://example.com">link1</a>.</p></section></main>"#
|
|
|
|
);
|
|
|
|
|
2019-06-26 22:12:41 +01:00
|
|
|
test_suite!(
|
2019-05-18 14:34:29 +01:00
|
|
|
section_and_headline,
|
2019-10-28 08:02:56 +00:00
|
|
|
r#"
|
|
|
|
* title 1
|
2019-08-09 15:15:06 +01:00
|
|
|
section 1
|
|
|
|
** title 2
|
|
|
|
section 2
|
|
|
|
* title 3
|
|
|
|
section 3
|
|
|
|
* title 4
|
2019-10-28 08:02:56 +00:00
|
|
|
section 4
|
|
|
|
"#,
|
2019-08-09 15:15:06 +01:00
|
|
|
"<main><h1>title 1</h1><section><p>section 1</p></section>\
|
|
|
|
<h2>title 2</h2><section><p>section 2</p></section>\
|
|
|
|
<h1>title 3</h1><section><p>section 3</p></section>\
|
|
|
|
<h1>title 4</h1><section><p>section 4</p></section></main>"
|
2019-04-24 14:54:51 +01:00
|
|
|
);
|
2019-04-08 12:35:38 +01:00
|
|
|
|
2019-06-26 22:12:41 +01:00
|
|
|
test_suite!(
|
2019-04-24 14:54:51 +01:00
|
|
|
list,
|
2019-10-28 08:02:56 +00:00
|
|
|
r#"
|
|
|
|
+ 1
|
2019-04-08 12:35:38 +01:00
|
|
|
|
|
|
|
+ 2
|
|
|
|
|
|
|
|
- 3
|
|
|
|
|
|
|
|
- 4
|
|
|
|
|
2019-10-28 08:02:56 +00:00
|
|
|
+ 5
|
|
|
|
"#,
|
2019-06-26 18:53:50 +01:00
|
|
|
"<main><section><ul>\
|
2019-04-24 14:54:51 +01:00
|
|
|
<li><p>1</p></li>\
|
|
|
|
<li><p>2</p><ul><li><p>3</p></li><li><p>4</p></li></ul></li>\
|
|
|
|
<li><p>5</p></li>\
|
2019-06-26 18:53:50 +01:00
|
|
|
</ul></section></main>"
|
2019-04-24 14:54:51 +01:00
|
|
|
);
|
2019-05-18 14:34:29 +01:00
|
|
|
|
2019-06-26 22:12:41 +01:00
|
|
|
test_suite!(
|
2019-05-18 14:34:29 +01:00
|
|
|
snippet,
|
|
|
|
"@@html:<del>@@delete this@@html:</del>@@",
|
2019-06-26 18:53:50 +01:00
|
|
|
"<main><section><p><del>delete this</del></p></section></main>"
|
2019-05-18 14:34:29 +01:00
|
|
|
);
|
2019-10-01 13:44:42 +01:00
|
|
|
|
|
|
|
test_suite!(
|
|
|
|
paragraphs,
|
2019-10-28 08:02:56 +00:00
|
|
|
r#"
|
|
|
|
* title
|
2019-10-01 13:44:42 +01:00
|
|
|
|
|
|
|
paragraph 1
|
|
|
|
|
|
|
|
paragraph 2
|
|
|
|
|
|
|
|
paragraph 3
|
|
|
|
|
2019-10-28 08:02:56 +00:00
|
|
|
paragraph 4
|
|
|
|
"#,
|
2019-10-01 13:44:42 +01:00
|
|
|
"<main><h1>title</h1><section>\
|
|
|
|
<p>paragraph 1</p><p>paragraph 2</p>\
|
|
|
|
<p>paragraph 3</p><p>paragraph 4</p>\
|
|
|
|
</section></main>"
|
|
|
|
);
|