use super::render_markdown; use super::*; #[test] fn escaped_special() { assert_eq!(special_escape(""), ""); assert_eq!(special_escape("<"), "<"); assert_eq!(special_escape(">"), ">"); assert_eq!(special_escape("<>"), "<>"); assert_eq!(special_escape(""), "<test>"); assert_eq!(special_escape("ab"), "a<test>b"); assert_eq!(special_escape("'"), "'"); assert_eq!(special_escape("\\"), "\"); assert_eq!(special_escape("&"), "&"); } #[test] fn preserves_external_links() { let options = HtmlRenderOptions::new(&Path::new("")); assert_eq!( render_markdown("[example](https://www.rust-lang.org/)", &options), "

example

\n" ); } #[test] fn it_can_adjust_markdown_links() { let options = HtmlRenderOptions::new(&Path::new("")); assert_eq!( render_markdown("[example](example.md)", &options), "

example

\n" ); assert_eq!( render_markdown("[example_anchor](example.md#anchor)", &options), "

example_anchor

\n" ); // this anchor contains 'md' inside of it assert_eq!( render_markdown("[phantom data](foo.html#phantomdata)", &options), "

phantom data

\n" ); } #[test] fn it_can_wrap_tables() { let src = r#" | Original | Punycode | Punycode + Encoding | |-----------------|-----------------|---------------------| | føø | f-5gaa | f_5gaa | "#; let out = r#"
OriginalPunycodePunycode + Encoding
føøf-5gaaf_5gaa
"#.trim(); let options = HtmlRenderOptions::new(&Path::new("")); assert_eq!(render_markdown(src, &options), out); } #[test] fn it_can_keep_quotes_straight() { let mut options = HtmlRenderOptions::new(&Path::new("")); options.markdown_options.smart_punctuation = false; assert_eq!(render_markdown("'one'", &options), "

'one'

\n"); } #[test] fn it_can_make_quotes_curly_except_when_they_are_in_code() { let input = r#" 'one' ``` 'two' ``` `'three'` 'four'"#; let expected = r#"

‘one’

'two'

'three' ‘four’

"#; let options = HtmlRenderOptions::new(&Path::new("")); assert_eq!(render_markdown(input, &options), expected); } #[test] fn whitespace_outside_of_codeblock_header_is_preserved() { let input = r#" some text with spaces ```rust fn main() { // code inside is unchanged } ``` more text with spaces "#; let expected = r#"

some text with spaces

fn main() {
// code inside is unchanged
}

more text with spaces

"#; let options = HtmlRenderOptions::new(&Path::new("")); assert_eq!(render_markdown(input, &options), expected); } #[test] fn rust_code_block_properties_are_passed_as_space_delimited_class() { let input = r#" ```rust,no_run,should_panic,property_3 ``` "#; let expected = r#"
"#; let options = HtmlRenderOptions::new(&Path::new("")); assert_eq!(render_markdown(input, &options), expected); } #[test] fn rust_code_block_properties_with_whitespace_are_passed_as_space_delimited_class() { let input = r#" ```rust, no_run,,,should_panic , ,property_3 ``` "#; let expected = r#"
"#; let options = HtmlRenderOptions::new(&Path::new("")); assert_eq!(render_markdown(input, &options), expected); } #[test] fn rust_code_block_without_properties_has_proper_html_class() { let input = r#" ```rust ``` "#; let expected = r#"
"#; let options = HtmlRenderOptions::new(&Path::new("")); assert_eq!(render_markdown(input, &options), expected); let input = r#" ```rust ``` "#; let options = HtmlRenderOptions::new(&Path::new("")); assert_eq!(render_markdown(input, &options), expected); }