extern crate markdown; use markdown::{ mdast::{Delete, Node, Paragraph, Root, Text}, to_html, to_html_with_options, to_mdast, unist::Position, Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; #[test] fn gfm_strikethrough() -> Result<(), String> { let gfm = Options { parse: ParseOptions { constructs: Constructs::gfm(), ..ParseOptions::default() }, ..Options::default() }; assert_eq!( to_html("a ~b~ c"), "
a ~b~ c
", "should ignore strikethrough by default" ); assert_eq!( to_html_with_options("a ~b~", &gfm)?, "a b
a b
a ~~~b~~~
", "should not support strikethrough w/ three tildes" ); assert_eq!( to_html_with_options("a \\~~~b~~ c", &gfm)?, "a ~b c
a b ec d
a -1 b
a b. c
b..
a one b
a two b
a ~~~three~~~ b
a ~~~~four~~~~ b
a ~one/two~~ b
a ~one/three~~~ b
a ~one/four~~~~ b
a ~~two/one~ b
a ~~two/three~~~ b
a ~~two/four~~~~ b
a ~~~three/one~ b
a ~~~three/two~~ b
a ~~~three/four~~~~ b
a ~~~~four/one~ b
a ~~~~four/two~~ b
a ~~~~four/three~~~ b
a one b one c one~ d
a one b two~~ c one d
a one b one c two~~ d
a two b two c two~~ d
a two b one~ c two d
a two b two c one~ d
a oneRight~ b oneRight~ c oneRight~ d
a oneRight~ b oneRight~ c ~oneLeft d
a oneRight~ b oneLeft c oneRight d
a oneLeft b oneRight c oneRight~ d
a oneLeft b oneRight c ~oneLeft d
a ~oneLeft b oneLeft c oneRight d
a ~oneLeft b ~oneLeft c ~oneLeft d
a twoRight~~ b twoRight~~ c twoRight~~ d
a twoRight~~ b twoRight~~ c ~~twoLeft d
a twoRight~~ b twoLeft c twoRight d
a twoLeft b twoRight c twoRight~~ d
a twoLeft b twoRight c ~~twoLeft d
a ~~twoLeft b twoLeft c twoRight d
a ~~twoLeft b ~~twoLeft c ~~twoLeft d
"###, "should handle flanking like GitHub" ); assert_eq!( to_html_with_options( r###" # Interlpay ## Interleave with attention a ~~two *emphasis* two~~ b a ~~two **strong** two~~ b a *marker ~~two marker* two~~ b a ~~two *marker two~~ marker* b ## Interleave with links a ~~two [resource](#) two~~ b a ~~two [reference][#] two~~ b a [label start ~~two label end](#) two~~ b a ~~two [label start two~~ label end](#) b a ~~two [label start ~one one~ label end](#) two~~ b a ~one [label start ~~two two~~ label end](#) one~ b a ~one [label start ~one one~ label end](#) one~ b a ~~two [label start ~~two two~~ label end](#) two~~ b [#]: # ## Interleave with code (text) a ~~two `code` two~~ b a ~~two `code two~~` b a `code start ~~two code end` two~~ b a ~~two `code start two~~ code end` b a ~~two `code start ~one one~ code end` two~~ b a ~one `code start ~~two two~~ code end` one~ b a ~one `code start ~one one~ code end` one~ b a ~~two `code start ~~two two~~ code end` two~~ b ## Emphasis/strong/strikethrough interplay a ***~~xxx~~*** zzz b ***xxx***zzz c **xxx**zzz d *xxx*zzz e ***~~xxx~~***yyy f **~~xxx~~**yyy g *~~xxx~~*yyy h ***~~xxx~~*** zzz i **~~xxx~~** zzz j *~~xxx~~* zzz k ~~~**xxx**~~~ zzz l ~~~xxx~~~zzz m ~~xxx~~zzz n ~xxx~zzz o ~~~**xxx**~~~yyy p ~~**xxx**~~yyy r ~**xxx**~yyy s ~~~**xxx**~~~ zzz t ~~**xxx**~~ zzz u ~**xxx**~ zzz "###, &gfm )?, r###"a two emphasis two b
a two strong two b
a marker ~~two marker two~~ b
a two *marker two marker* b
a two resource two b
a two reference two b
a label start ~~two label end two~~ b
a ~~two label start two~~ label end b
a two label start bone one label end two
a one label start btwo two label end one
a one label start bone one label end one
a two label start btwo two label end two
a two bcode
two
a ~~two code two~~
b
a code start ~~two code end
two~~ b
a ~~two code start two~~ code end
b
a two bcode start ~one one~ code end
two
a one bcode start ~~two two~~ code end
one
a one bcode start ~one one~ code end
one
a two bcode start ~~two two~~ code end
two
a xxx zzz
b xxxzzz
c xxxzzz
d xxxzzz
e xxxyyy
f xxxyyy
g xxxyyy
h xxx zzz
i xxx zzz
j xxx zzz
k ~~~xxx~~~ zzz
l ~~~xxx~~~zzz
m xxxzzz
n xxxzzz
o ~~~xxx~~~yyy
p ~~xxx~~yyy
r ~xxx~yyy
s ~~~xxx~~~ zzz
t xxx zzz
u xxx zzz
a ~b~ c d
a b c d