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() { assert_eq!( render_markdown("[example](https://www.rust-lang.org/)", false), "

example

\n" ); } #[test] fn it_can_adjust_markdown_links() { assert_eq!( render_markdown("[example](example.md)", false), "

example

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

example_anchor

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

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(); assert_eq!(render_markdown(src, false), out); } #[test] fn it_can_keep_quotes_straight() { assert_eq!(render_markdown("'one'", false), "

'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’

"#; assert_eq!(render_markdown(input, true), 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

"#; assert_eq!(render_markdown(input, false), expected); assert_eq!(render_markdown(input, true), 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#"
"#; assert_eq!(render_markdown(input, false), expected); assert_eq!(render_markdown(input, true), 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#"
"#; assert_eq!(render_markdown(input, false), expected); assert_eq!(render_markdown(input, true), expected); } #[test] fn rust_code_block_without_properties_has_proper_html_class() { let input = r#" ```rust ``` "#; let expected = r#"
"#; assert_eq!(render_markdown(input, false), expected); assert_eq!(render_markdown(input, true), expected); let input = r#" ```rust ``` "#; assert_eq!(render_markdown(input, false), expected); assert_eq!(render_markdown(input, true), expected); }