From ec2d1bfb4232178fb3a6cba36f138bc6efbbf34a Mon Sep 17 00:00:00 2001
From: Titus Wormer [foo]: /url [foo] [foo]: /url 'title with blank line' [foo] [foo]: [foo] [foo]: [foo] [İ] [i] bar [foo]: /url "title" ok "title" ok [foo] [foo] Foo\n[bar]: /baz [bar] bar ===\nfoo Link: [+]. [x]: < [x]
\n[foo]: /url "title"\n
\n[foo]: /url\n
Foo
\n\n
",
"should not support definitions in headings"
);
assert_eq!(
- micromark("[foo]: /url\nbar\n===\n[foo]"),
+ to_html("[foo]: /url\nbar\n===\n[foo]"),
"bar
\n",
"should support setext headings after definitions"
);
assert_eq!(
- micromark("[foo]: /url\n===\n[foo]"),
+ to_html("[foo]: /url\n===\n[foo]"),
"\n
\n",
"should support definitions in block quotes (1)"
);
assert_eq!(
- micromark("> [a]: <> 'b\n> c'"),
+ to_html("> [a]: <> 'b\n> c'"),
"\n
",
"should support definitions in block quotes (2)"
);
assert_eq!(
- micromark("> [a]\n\n[a]: b (c\n)"),
+ to_html("> [a]\n\n[a]: b (c\n)"),
"\n\n
\n",
"should support definitions in block quotes (3)"
);
// Extra
assert_eq!(
- micromark("[\\[\\+\\]]: example.com\n\nLink: [\\[\\+\\]]."),
+ to_html("[\\[\\+\\]]: example.com\n\nLink: [\\[\\+\\]]."),
"
[x]
", "should not support a line ending in enclosed destination" ); assert_eq!( - micromark("[x]: \u{000b}a\n\n[x]"), + to_html("[x]: \u{000b}a\n\n[x]"), "[x]: \u{000b}a
\n[x]
", "should not support ascii control characters at the start of destination" ); assert_eq!( - micromark("[x]: a\u{000b}b\n\n[x]"), + to_html("[x]: a\u{000b}b\n\n[x]"), "[x]: a\u{000b}b
\n[x]
", "should not support ascii control characters in destination" ); assert_eq!( - micromark("[x]: <\u{000b}a>\n\n[x]"), + to_html("[x]: <\u{000b}a>\n\n[x]"), "", "should support ascii control characters at the start of enclosed destination" ); assert_eq!( - micromark("[x]: \n\n[x]"), + to_html("[x]: \n\n[x]"), "", "should support ascii control characters in enclosed destinations" ); assert_eq!( - micromark("[x]: a \"\\\"\"\n\n[x]"), + to_html("[x]: a \"\\\"\"\n\n[x]"), "", "should support character escapes at the start of a title" ); assert_eq!( - micromark("[x]: a \"'\"\n\n[x]"), + to_html("[x]: a \"'\"\n\n[x]"), "", "should support double quoted titles" ); assert_eq!( - micromark("[x]: a '\"'\n\n[x]"), + to_html("[x]: a '\"'\n\n[x]"), "", "should support single quoted titles" ); assert_eq!( - micromark("[x]: a (\"')\n\n[x]"), + to_html("[x]: a (\"')\n\n[x]"), "", "should support paren enclosed titles" ); assert_eq!( - micromark("[x]: a(()\n\n[x]"), + to_html("[x]: a(()\n\n[x]"), "[x]: a(()
\n[x]
", "should not support more opening than closing parens in the destination" ); assert_eq!( - micromark("[x]: a(())\n\n[x]"), + to_html("[x]: a(())\n\n[x]"), "", "should support balanced opening and closing parens in the destination" ); assert_eq!( - micromark("[x]: a())\n\n[x]"), + to_html("[x]: a())\n\n[x]"), "[x]: a())
\n[x]
", "should not support more closing than opening parens in the destination" ); assert_eq!( - micromark("[x]: a \t\n\n[x]"), + to_html("[x]: a \t\n\n[x]"), "", "should support trailing whitespace after a destination" ); assert_eq!( - micromark("[x]: a \"X\" \t\n\n[x]"), + to_html("[x]: a \"X\" \t\n\n[x]"), "", "should support trailing whitespace after a title" ); assert_eq!( - micromark("[&©&]: example.com/&©& \"&©&\"\n\n[&©&]"), + to_html("[&©&]: example.com/&©& \"&©&\"\n\n[&©&]"), "", "should support character references in definitions" ); assert_eq!( - micromark("[x]:\nexample.com\n\n[x]"), + to_html("[x]:\nexample.com\n\n[x]"), "", "should support a line ending before a destination" ); assert_eq!( - micromark("[x]: \t\nexample.com\n\n[x]"), + to_html("[x]: \t\nexample.com\n\n[x]"), "", "should support whitespace before a destination" ); // See:[a]
\n[a]: <b
[a]
\n[a]: b(c
", "should not support an extra left paren (`(`) in a raw destination" ); assert_eq!( - micromark("[a]\n\n[a]: b)c"), + to_html("[a]\n\n[a]: b)c"), "[a]
\n[a]: b)c
", "should not support an extra right paren (`)`) in a raw destination" ); assert_eq!( - micromark("[a]\n\n[a]: b)c"), + to_html("[a]\n\n[a]: b)c"), "[a]
\n[a]: b)c
", "should not support an extra right paren (`)`) in a raw destination" ); assert_eq!( - micromark("[a]\n\n[a]: a(1(2(3(4()))))b"), + to_html("[a]\n\n[a]: a(1(2(3(4()))))b"), "\n", "should support 4 or more sets of parens in a raw destination (link resources don’t)" ); assert_eq!( - micromark("[a]\n\n[a]: aaa)"), + to_html("[a]\n\n[a]: aaa)"), "[a]
\n[a]: aaa)
", "should not support a final (unbalanced) right paren in a raw destination" ); assert_eq!( - micromark("[a]\n\n[a]: aaa) \"a\""), + to_html("[a]\n\n[a]: aaa) \"a\""), "[a]
\n[a]: aaa) "a"
", "should not support a final (unbalanced) right paren in a raw destination “before” a title" ); assert_eq!( - micromark(" [a]: b \"c\"\n [d]: e\n [f]: g \"h\"\n [i]: j\n\t[k]: l (m)\n\t n [k] o"), + to_html(" [a]: b \"c\"\n [d]: e\n [f]: g \"h\"\n [i]: j\n\t[k]: l (m)\n\t n [k] o"), "n k o
", "should support subsequent indented definitions" ); assert_eq!( - micromark("[a\n b]: c\n\n[a\n b]"), + to_html("[a\n b]: c\n\n[a\n b]"), "", "should support line prefixes in definition labels" ); assert_eq!( - micromark("[a]: )\n\n[a]"), + to_html("[a]: )\n\n[a]"), "[a]: )
\n[a]
", "should not support definitions w/ only a closing paren as a raw destination" ); assert_eq!( - micromark("[a]: )b\n\n[a]"), + to_html("[a]: )b\n\n[a]"), "[a]: )b
\n[a]
", "should not support definitions w/ closing paren + more text as a raw destination" ); assert_eq!( - micromark("[a]: b)\n\n[a]"), + to_html("[a]: b)\n\n[a]"), "[a]: b)
\n[a]
", "should not support definitions w/ text + a closing paren as a raw destination" ); assert_eq!( - micromark("[\na\n=\n]: b"), + to_html("[\na\n=\n]: b"), "]: b
", "should prefer setext headings over definition labels" ); assert_eq!( - micromark("[a]: b '\nc\n=\n'"), + to_html("[a]: b '\nc\n=\n'"), "'
", "should prefer setext headings over definition titles" ); assert_eq!( - micromark("[\n***\n]: b"), + to_html("[\n***\n]: b"), "[
\n]: b
", "should prefer thematic breaks over definition labels" ); assert_eq!( - micromark("[a]: b '\n***\n'"), + to_html("[a]: b '\n***\n'"), "[a]: b '
\n'
", "should prefer thematic breaks over definition titles" ); assert_eq!( - micromark("[\n```\n]: b"), + to_html("[\n```\n]: b"), "[
\n]: b\n
\n",
"should prefer code (fenced) over definition labels"
);
assert_eq!(
- micromark("[a]: b '\n```\n'"),
+ to_html("[a]: b '\n```\n'"),
"[a]: b '
\n'\n
\n",
"should prefer code (fenced) over definition titles"
);
assert_eq!(
- micromark_with_options(
+ to_html_with_options(
"[foo]: /url \"title\"",
&Options {
parse: ParseOptions {
@@ -503,7 +503,7 @@ fn definition() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("[a]: 'c'", &ParseOptions::default())?,
+ to_mdast("[a]: 'c'", &ParseOptions::default())?,
Node::Root(Root {
children: vec![Node::Definition(Definition {
url: "b".into(),
--
cgit