extern crate micromark; use micromark::{micromark, micromark_with_options, Constructs, Options}; use pretty_assertions::assert_eq; #[test] fn gfm_footnote() -> Result<(), String> { let gfm = Options { constructs: Constructs::gfm(), ..Options::default() }; assert_eq!( micromark("A call.[^a]\n\n[^a]: whatevs"), "
A call.^a
\n", "should ignore footnotes by default" ); assert_eq!( micromark_with_options("A call.[^a]\n\n[^a]: whatevs", &gfm)?, "A call.1
whatevs ↩
Noot.1
dingen ↩
b ↩
b ↩
b ↩
A paragraph.
\n", "should ignore definitions w/o calls" ); assert_eq!( micromark_with_options("a[^b]", &gfm)?, "a[^b]
", "should ignore calls w/o definitions" ); assert_eq!( micromark_with_options("a[^b]\n\n[^b]: c\n[^b]: d", &gfm)?, "a1
c ↩
!^a
", "should not support images starting w/ `^` (but see it as a link?!, 1)" ); assert_eq!( micromark_with_options("![^a][b]\n\n[b]: c", &gfm)?, "!^a
\n", "should not support images starting w/ `^` (but see it as a link?!, 2)" ); assert_eq!( micromark_with_options("[^]()", &gfm)?, "", "should support an empty link with caret" ); assert_eq!( micromark_with_options("![^]()", &gfm)?, "!^
", "should support an empty image with caret (as link)" ); //Call.1.
y ↩
Call.1.
y ↩
Call.1.
y ↩
Call.1.
y ↩
Call.[^a+b].
\n", "should match calls to definitions on the source of the label, not on resolved escapes" ); assert_eq!( micromark_with_options("Call.[^a[b].\n\n[^a\\[b]: y", &gfm)?, "Call.[^a[b].
\n", "should match calls to definitions on the source of the label, not on resolved references" ); assert_eq!( micromark_with_options("[^1].\n\n[^1]: a\nb", &gfm)?, "1.
a b ↩
1.
a b ↩
1.
a b ↩
1.
a
↩b
Call.1.
y ↩
Call.[^a{}].
\n[^a{}]: y
", max, max), "should not support 1000 characters in a call / definition" ); assert_eq!( micromark_with_options( r###"a![i](#) a\![i](#) a![i][] a![^1] [^1] ^1] [^1]: b [i]: c"###, &gfm )?, r###"a![^1]
", "should match bang/caret interplay (undefined) like GitHub" ); assert_eq!( micromark_with_options( r###"a![^1] [^1]: b "###, &gfm )?, r###"a!1
b ↩
Calls may not be empty: ^.
Calls cannot contain whitespace only: ^ .
Calls cannot contain whitespace at all: ^ , ^ , ^ .
Calls can contain other characters, such as numbers 1, or 2 even another caret.
^ : line feed
[^link]
[^]
[^link]: a
[^]: a
More.
More.
block quote
Lazy?
Lazy!
Call1
a ↩
emphasis1
strong2
code[^3]
[link4](#)
What are these!1, !2[], and ![this]3.
block quote
What are these1, 2[], and [this]3.
block quote
block quote
Here is a footnote reference,1 and another.2
This paragraph won’t be part of the note, because it isn’t indented.
[^1]: 5
[^2]: 4
3
3
3
2
1
0
Here is a short reference,1, a collapsed one,2, and a full one.
"###, "should match references and definitions like GitHub" ); Ok(()) }