extern crate hoedown; use hoedown::{Markdown, Render}; use hoedown::renderer::html; macro_rules! extensions_test { ($extension:ident: $left:expr, $right:expr) => ({ let mut renderer = html::Html::new(html::Flags::empty(), 0); let doc = Markdown::new($left) .extensions(hoedown::$extension); assert_eq!(renderer.render(&doc).to_str().unwrap(), $right); }); } #[test] fn test_hard_wrap() { extensions_test!(AUTOLINK: "https://github.com/", "
\n"); } #[test] fn test_fenced_code() { extensions_test!(FENCED_CODE: "```\n$ :(){ :|:& };:\n```", "$ :(){ :|:& };:\n
\n");
}
#[test]
fn test_fenced_code_lang() {
extensions_test!(FENCED_CODE:
"```bash\n$ :(){ :|:& };:\n```",
"$ :(){ :|:& };:\n
\n");
}
#[test]
fn test_footnotes() {
extensions_test!(FOOTNOTES:
"What you looking at? [^1]\n\n[^1]: Yeah, I\'m talking to you pal.",
"What you looking at? 1
Yeah, I'm talking to you pal. ↩
I'm special.
\n"); } #[test] fn test_no_indented_code() { extensions_test!(DISABLE_INDENTED_CODE: " $ :(){ :|:& };:", "$ :(){ :|:& };:
\n"); } #[test] fn test_no_intra_emphasis() { extensions_test!(NO_INTRA_EMPHASIS: "Sorry,_my_space_key_is_broken.", "Sorry,_my_space_key_is_broken.
\n"); } #[test] fn test_quote() { extensions_test!(QUOTE: r#""Air quotes are obnoxious.""#, "Air quotes are obnoxious.
#Are you listening to me?!
\n"); } #[test] fn test_strikethrough() { extensions_test!(STRIKETHROUGH: "I\'m ~~running~~ out of ideas.", "I'm running out of ideas.
bro
\n"); } #[test] fn test_tables() { extensions_test!(TABLES: "| 1 | 2 | 3 | | --- | --- | --- | | X | X | O | | O | O | X | | X | O | X | ", "1 | 2 | 3 |
---|---|---|
X | X | O |
O | O | X |
X | O | X |
What do you mean?
\n"); }