extern crate markdown; use markdown::{ mdast::{Node, Root, ThematicBreak}, to_html, to_html_with_options, to_mdast, unist::Position, Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; #[test] fn thematic_break() -> Result<(), String> { assert_eq!( to_html("***\n---\n___"), "
+++
", "should not support thematic breaks w/ plusses" ); assert_eq!( to_html("==="), "===
", "should not support thematic breaks w/ equals" ); assert_eq!( to_html("--"), "--
", "should not support thematic breaks w/ two dashes" ); assert_eq!( to_html("**"), "**
", "should not support thematic breaks w/ two asterisks" ); assert_eq!( to_html("__"), "__
", "should not support thematic breaks w/ two underscores" ); assert_eq!( to_html(" ***"), "***\n
",
"should not support thematic breaks w/ 4 spaces"
);
assert_eq!(
to_html("Foo\n ***"),
"Foo\n***
", "should not support thematic breaks w/ 4 spaces as paragraph continuation" ); assert_eq!( to_html("_____________________________________"), "_ _ _ _ a
", "should not support thematic breaks w/ other characters (1)" ); assert_eq!( to_html("a------"), "a------
", "should not support thematic breaks w/ other characters (2)" ); assert_eq!( to_html("---a---"), "---a---
", "should not support thematic breaks w/ other characters (3)" ); assert_eq!( to_html(" *-*"), "-
", "should not support thematic breaks w/ mixed markers" ); assert_eq!( to_html("- foo\n***\n- bar"), "Foo
\nbar
", "should support thematic breaks interrupting paragraphs" ); assert_eq!( to_html("Foo\n---\nbar"), "bar
", "should not support thematic breaks w/ dashes interrupting paragraphs (setext heading)" ); assert_eq!( to_html("- Foo\n- * * *"), "\n\n
\n
a
", "should not support lazyness (1)" ); assert_eq!( to_html("> a\n---"), "\n\na
\n
***
", "should support turning off thematic breaks" ); assert_eq!( to_mdast("***", &ParseOptions::default())?, Node::Root(Root { children: vec![Node::ThematicBreak(ThematicBreak { position: Some(Position::new(1, 1, 0, 1, 4, 3)) })], position: Some(Position::new(1, 1, 0, 1, 4, 3)) }), "should support thematic breaks as `ThematicBreak`s in mdast" ); Ok(()) }