extern crate micromark; use micromark::{micromark, micromark_with_options, Options}; const DANGER: &Options = &Options { allow_dangerous_html: true, allow_dangerous_protocol: true, default_line_ending: None, }; #[test] fn tabs_flow() { assert_eq!( micromark(" x"), "
x\n
",
"should support a 4*SP to start code"
);
assert_eq!(
micromark("\tx"),
"x\n
",
"should support a HT to start code"
);
assert_eq!(
micromark(" \tx"),
"x\n
",
"should support a SP + HT to start code"
);
assert_eq!(
micromark(" \tx"),
"x\n
",
"should support a 2*SP + HT to start code"
);
assert_eq!(
micromark(" \tx"),
"x\n
",
"should support a 3*SP + HT to start code"
);
assert_eq!(
micromark(" \tx"),
"\tx\n
",
"should support a 4*SP to start code, and leave the next HT as code data"
);
assert_eq!(
micromark(" \t# x"),
"# x\n
",
"should not support a 3*SP + HT to start an ATX heading"
);
assert_eq!(
micromark(" \t> x"),
"> x\n
",
"should not support a 3*SP + HT to start a block quote"
);
assert_eq!(
micromark(" \t- x"),
"- x\n
",
"should not support a 3*SP + HT to start a list item"
);
assert_eq!(
micromark(" \t---"),
"---\n
",
"should not support a 3*SP + HT to start a thematic break"
);
assert_eq!(
micromark(" \t---"),
"---\n
",
"should not support a 3*SP + HT to start a thematic break"
);
assert_eq!(
micromark(" \t```"),
"```\n
",
"should not support a 3*SP + HT to start a fenced code"
);
assert_eq!(
micromark(" \t<div>\n
",
"should not support a 3*SP + HT to start HTML"
);
assert_eq!(
micromark("#\tx\t#\t"),
"
",
"should support tabs around fenced code fences, info, and meta"
);
assert_eq!(
micromark("```\t\tx\t\ty\t\t\n```\t\t"),
"
",
"should support arbitrary tabs around fenced code fences, info, and meta"
);
assert_eq!(
micromark("```x\n\t```"),
"\t```\n
\n",
"should not support tabs before fenced code closing fences"
);
assert_eq!(
micromark_with_options("<http:\t>
", "should not support a tab to start an autolink w/ protocol’s rest" ); assert_eq!( micromark("<http:x\t>
", "should not support a tab in an autolink w/ protocol’s rest" ); assert_eq!( micromark("<example\t@x.com>
", "should not support a tab in an email autolink’s local part" ); assert_eq!( micromark("<example@x\ty.com>
", "should not support a tab in an email autolink’s label" ); assert_eq!( micromark("\\\tx"), "\\\tx
", "should not support character escaped tab" ); assert_eq!( micromark(" "), "\t
", "should support character reference resolving to a tab" ); assert_eq!( micromark("`\tx`"), "\tx
x\t
\tx\t
\tx
x\t
x\ny
", "should support a trailing tab at a line ending in a paragraph" ); assert_eq!( micromark("x\n\ty"), "x\ny
", "should support an initial tab after a line ending in a paragraph" ); assert_eq!( micromark("x[\ty](z)"), "x\ty
", "should support an initial tab in a link label" ); assert_eq!( micromark("x[y\t](z)"), "xy\t
", "should support a final tab in a link label" ); assert_eq!( micromark("[x\ty](z)"), "", "should support a tab in a link label" ); // Note: CM.js bug, see:\tx\n
\n",
"should support a tab in fenced code"
);
assert_eq!(
micromark(" ```\n\tx"),
" x\n
\n",
"should strip 1 space from an initial tab in fenced code if the opening fence is indented as such"
);
assert_eq!(
micromark(" ```\n\tx"),
" x\n
\n",
"should strip 2 spaces from an initial tab in fenced code if the opening fence is indented as such"
);
assert_eq!(
micromark(" ```\n\tx"),
" x\n
\n",
"should strip 3 spaces from an initial tab in fenced code if the opening fence is indented as such"
);
}