extern crate micromark; use micromark::{micromark, micromark_with_options, Options}; use pretty_assertions::assert_eq; #[test] fn line_ending() -> Result<(), String> { let danger = &Options { allow_dangerous_html: true, allow_dangerous_protocol: true, ..Options::default() }; assert_eq!(micromark("\n"), "", "should support just a line feed"); assert_eq!(micromark("\r"), "", "should support just a carriage return"); assert_eq!( micromark("\r\n"), "", "should support just a carriage return + line feed" ); assert_eq!(micromark("\n\n"), "", "should support just two line feeds"); assert_eq!( micromark("\r\r"), "", "should support just two carriage return" ); assert_eq!( micromark("\r\n\r\n"), "", "should support just two carriage return + line feeds" ); assert_eq!( micromark("a\nb"), "
a\nb
", "should support a line feed for a line ending inside a paragraph" ); assert_eq!( micromark("a\rb"), "a\rb
", "should support a carriage return for a line ending inside a paragraph" ); assert_eq!( micromark("a\r\nb"), "a\r\nb
", "should support a carriage return + line feed for a line ending inside a paragraph" ); assert_eq!( micromark("\ta\n\tb"), "a\nb\n
",
"should support a line feed in indented code (and prefer it)"
);
assert_eq!(
micromark("\ta\r\tb"),
"a\rb\r
",
"should support a carriage return in indented code (and prefer it)"
);
assert_eq!(
micromark("\ta\r\n\tb"),
"a\r\nb\r\n
",
"should support a carriage return + line feed in indented code (and prefer it)"
);
assert_eq!(
micromark("***\n### Heading"),
"\n\ny\n\n\n
\n",
"should support several line feeds in fenced code"
);
assert_eq!(
micromark("```x\r\r\ry\r\r\r```\r\r\r"),
"\r\ry\r\r\r
\r",
"should support several carriage returns in fenced code"
);
assert_eq!(
micromark("```x\r\n\r\n\r\ny\r\n\r\n\r\n```\r\n\r\n\r\n"),
"\r\n\r\ny\r\n\r\n\r\n
\r\n",
"should support several carriage return + line feeds in fenced code"
);
assert_eq!(
micromark("A\r\nB\r\n-\r\nC"),
"C
", "should support a carriage return + line feed in content" ); assert_eq!( micromark_with_options("x
", "should support a blank line w/ line feeds after html" ); assert_eq!( micromark_with_options("x
", "should support a blank line w/ carriage returns after html" ); assert_eq!( micromark_with_options("x
", "should support a blank line w/ carriage return + line feeds after html" ); assert_eq!( micromark_with_options("