use markdown::{to_html, to_html_with_options, CompileOptions, LineEnding, Options}; use pretty_assertions::assert_eq; #[test] fn default_line_ending() -> Result<(), String> { assert_eq!( to_html("> a"), "
\n

a

\n
", "should use `\\n` default" ); assert_eq!( to_html("> a\n"), "
\n

a

\n
\n", "should infer the first line ending (1)" ); assert_eq!( to_html("> a\r"), "
\r

a

\r
\r", "should infer the first line ending (2)" ); assert_eq!( to_html("> a\r\n"), "
\r\n

a

\r\n
\r\n", "should infer the first line ending (3)" ); assert_eq!( to_html_with_options( "> a", &Options { compile: CompileOptions { default_line_ending: LineEnding::CarriageReturn, ..Default::default() }, ..Default::default() } )?, "
\r

a

\r
", "should support the given line ending" ); assert_eq!( to_html_with_options( "> a\n", &Options { compile: CompileOptions { default_line_ending: LineEnding::CarriageReturn, ..Default::default() }, ..Default::default() } )?, // To do: is this a bug in `to_html.js` that it uses `\r` for earlier line endings? // "
\r

a

\r
\n", "
\n

a

\n
\n", "should support the given line ending, even if line endings exist" ); Ok(()) }