From ec2d1bfb4232178fb3a6cba36f138bc6efbbf34a Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 13 Oct 2022 10:40:01 +0200 Subject: Rename crate to `markdown` --- tests/definition.rs | 164 ++++++++++++++++++++++++++-------------------------- 1 file changed, 82 insertions(+), 82 deletions(-) (limited to 'tests/definition.rs') diff --git a/tests/definition.rs b/tests/definition.rs index 376035a..c6923bc 100644 --- a/tests/definition.rs +++ b/tests/definition.rs @@ -1,7 +1,7 @@ -extern crate micromark; -use micromark::{ +extern crate markdown; +use markdown::{ mdast::{Definition, Node, Root}, - micromark, micromark_to_mdast, micromark_with_options, + to_html, to_html_with_options, to_mdast, unist::Position, CompileOptions, Constructs, Options, ParseOptions, }; @@ -19,473 +19,473 @@ fn definition() -> Result<(), String> { }; assert_eq!( - micromark("[foo]: /url \"title\"\n\n[foo]"), + to_html("[foo]: /url \"title\"\n\n[foo]"), "

foo

", "should support link definitions" ); assert_eq!( - micromark("[foo]:\n\n/url\n\n[foo]"), + to_html("[foo]:\n\n/url\n\n[foo]"), "

[foo]:

\n

/url

\n

[foo]

", "should not support blank lines before destination" ); assert_eq!( - micromark(" [foo]: \n /url \n 'the title' \n\n[foo]"), + to_html(" [foo]: \n /url \n 'the title' \n\n[foo]"), "

foo

", "should support whitespace and line endings in definitions" ); assert_eq!( - micromark("[a]:b 'c'\n\n[a]"), + to_html("[a]:b 'c'\n\n[a]"), "

a

", "should support no whitespace after `:` in definitions" ); assert_eq!( - micromark("[Foo*bar\\]]:my_(url) 'title (with parens)'\n\n[Foo*bar\\]]"), + to_html("[Foo*bar\\]]:my_(url) 'title (with parens)'\n\n[Foo*bar\\]]"), "

Foo*bar]

", "should support complex definitions (1)" ); assert_eq!( - micromark("[Foo bar]:\n\n'title'\n\n[Foo bar]"), + to_html("[Foo bar]:\n\n'title'\n\n[Foo bar]"), "

Foo bar

", "should support complex definitions (2)" ); assert_eq!( - micromark("[foo]: /url '\ntitle\nline1\nline2\n'\n\n[foo]"), + to_html("[foo]: /url '\ntitle\nline1\nline2\n'\n\n[foo]"), "

foo

", "should support line endings in titles" ); assert_eq!( - micromark("[foo]: /url 'title\n\nwith blank line'\n\n[foo]"), + to_html("[foo]: /url 'title\n\nwith blank line'\n\n[foo]"), "

[foo]: /url 'title

\n

with blank line'

\n

[foo]

", "should not support blank lines in titles" ); assert_eq!( - micromark("[foo]:\n/url\n\n[foo]"), + to_html("[foo]:\n/url\n\n[foo]"), "

foo

", "should support definitions w/o title" ); assert_eq!( - micromark("[foo]:\n\n[foo]"), + to_html("[foo]:\n\n[foo]"), "

[foo]:

\n

[foo]

", "should not support definitions w/o destination" ); assert_eq!( - micromark("[foo]: <>\n\n[foo]"), + to_html("[foo]: <>\n\n[foo]"), "

foo

", "should support definitions w/ explicit empty destinations" ); assert_eq!( - micromark_with_options("[foo]: (baz)\n\n[foo]", &danger)?, + to_html_with_options("[foo]: (baz)\n\n[foo]", &danger)?, "

[foo]: (baz)

\n

[foo]

", "should not support definitions w/ no whitespace between destination and title" ); assert_eq!( - micromark("[foo]: /url\\bar\\*baz \"foo\\\"bar\\baz\"\n\n[foo]"), + to_html("[foo]: /url\\bar\\*baz \"foo\\\"bar\\baz\"\n\n[foo]"), "

foo

", "should support character escapes in destinations and titles" ); assert_eq!( - micromark("[foo]\n\n[foo]: url"), + to_html("[foo]\n\n[foo]: url"), "

foo

\n", "should support a link before a definition" ); assert_eq!( - micromark("[foo]: first\n[foo]: second\n\n[foo]"), + to_html("[foo]: first\n[foo]: second\n\n[foo]"), "

foo

", "should match w/ the first definition" ); assert_eq!( - micromark("[FOO]: /url\n\n[Foo]"), + to_html("[FOO]: /url\n\n[Foo]"), "

Foo

", "should match w/ case-insensitive (1)" ); assert_eq!( - micromark("[ΑΓΩ]: /φου\n\n[αγω]"), + to_html("[ΑΓΩ]: /φου\n\n[αγω]"), "

αγω

", "should match w/ case-insensitive (2)" ); assert_eq!( - micromark("[ı]: a\n\n[I]"), + to_html("[ı]: a\n\n[I]"), "

I

", "should match w/ undotted turkish i (1)" ); assert_eq!( - micromark("[I]: a\n\n[ı]"), + to_html("[I]: a\n\n[ı]"), "

ı

", "should match w/ undotted turkish i (2)" ); // Ref: // GFM parses the same (last checked: 2022-07-11). assert_eq!( - micromark("[i]: a\n\n[İ]"), + to_html("[i]: a\n\n[İ]"), "

[İ]

", "should *not* match w/ dotted turkish i (1)" ); // Ref: // GFM parses the same (last checked: 2022-07-11). assert_eq!( - micromark("[İ]: a\n\n[i]"), + to_html("[İ]: a\n\n[i]"), "

[i]

", "should *not* match w/ dotted turkish i (2)" ); assert_eq!( - micromark("[foo]: /url"), + to_html("[foo]: /url"), "", "should not contribute anything w/o reference (1)" ); assert_eq!( - micromark("[\nfoo\n]: /url\nbar"), + to_html("[\nfoo\n]: /url\nbar"), "

bar

", "should not contribute anything w/o reference (2)" ); assert_eq!( - micromark("[foo]: /url \"title\" \n\n[foo]"), + to_html("[foo]: /url \"title\" \n\n[foo]"), "

foo

", "should support whitespace after title" ); assert_eq!( - micromark("[foo]: /url\n\"title\" \n\n[foo]"), + to_html("[foo]: /url\n\"title\" \n\n[foo]"), "

foo

", "should support whitespace after title on a separate line" ); assert_eq!( - micromark("[foo]: /url \"title\" ok"), + to_html("[foo]: /url \"title\" ok"), "

[foo]: /url "title" ok

", "should not support non-whitespace content after definitions (1)" ); assert_eq!( - micromark("[foo]: /url\n\"title\" ok"), + to_html("[foo]: /url\n\"title\" ok"), "

"title" ok

", "should not support non-whitespace content after definitions (2)" ); assert_eq!( - micromark(" [foo]: /url \"title\"\n\n[foo]"), + to_html(" [foo]: /url \"title\"\n\n[foo]"), "
[foo]: /url "title"\n
\n

[foo]

", "should prefer indented code over definitions" ); assert_eq!( - micromark("```\n[foo]: /url\n```\n\n[foo]"), + to_html("```\n[foo]: /url\n```\n\n[foo]"), "
[foo]: /url\n
\n

[foo]

", "should not support definitions in fenced code" ); assert_eq!( - micromark("Foo\n[bar]: /baz\n\n[bar]"), + to_html("Foo\n[bar]: /baz\n\n[bar]"), "

Foo\n[bar]: /baz

\n

[bar]

", "should not support definitions in paragraphs" ); assert_eq!( - micromark("# [Foo]\n[foo]: /url\n> bar"), + to_html("# [Foo]\n[foo]: /url\n> bar"), "

Foo

\n
\n

bar

\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

foo

", "should support setext headings after definitions" ); assert_eq!( - micromark("[foo]: /url\n===\n[foo]"), + to_html("[foo]: /url\n===\n[foo]"), "

===\nfoo

", "should not support setext heading underlines after definitions" ); assert_eq!( - micromark( + to_html( "[foo]: /foo-url \"foo\"\n[bar]: /bar-url\n \"bar\"\n[baz]: /baz-url\n\n[foo],\n[bar],\n[baz]"), "

foo,\nbar,\nbaz

", "should support definitions after definitions" ); assert_eq!( - micromark("> [foo]: /url\n\n[foo]"), + to_html("> [foo]: /url\n\n[foo]"), "
\n
\n

foo

", "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

a

\n
\n", "should support definitions in block quotes (3)" ); // Extra assert_eq!( - micromark("[\\[\\+\\]]: example.com\n\nLink: [\\[\\+\\]]."), + to_html("[\\[\\+\\]]: example.com\n\nLink: [\\[\\+\\]]."), "

Link: [+].

", "should match w/ character escapes" ); assert_eq!( - micromark("[x]: \\\" \\(\\)\\\"\n\n[x]"), + to_html("[x]: \\\" \\(\\)\\\"\n\n[x]"), "

x

", "should support character escapes & references in unenclosed destinations" ); assert_eq!( - micromark("[x]: <\\> \\+\\>>\n\n[x]"), + to_html("[x]: <\\> \\+\\>>\n\n[x]"), "

x

", "should support character escapes & references in enclosed destinations" ); assert_eq!( - micromark("[x]: <\n\n[x]"), + to_html("[x]: <\n\n[x]"), "

[x]: <

\n

[x]

", "should not support a line ending at start of enclosed destination" ); assert_eq!( - micromark("[x]: [x]: <x

\n

[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]"), "

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]"), "

x

", "should support ascii control characters in enclosed destinations" ); assert_eq!( - micromark("[x]: a \"\\\"\"\n\n[x]"), + to_html("[x]: a \"\\\"\"\n\n[x]"), "

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]"), "

x

", "should support double quoted titles" ); assert_eq!( - micromark("[x]: a '\"'\n\n[x]"), + to_html("[x]: a '\"'\n\n[x]"), "

x

", "should support single quoted titles" ); assert_eq!( - micromark("[x]: a (\"')\n\n[x]"), + to_html("[x]: a (\"')\n\n[x]"), "

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]"), "

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]"), "

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]"), "

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]"), "

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]"), "

x

", "should support whitespace before a destination" ); // See: assert_eq!( - micromark("[x]: <> \"\"\n[][x]"), + to_html("[x]: <> \"\"\n[][x]"), "

", "should ignore an empty title" ); assert_eq!( - micromark_with_options("[a]\n\n[a]: ", &danger)?, + to_html_with_options("[a]\n\n[a]: ", &danger)?, "

[a]

\n

[a]: <b

", "should not support a less than in an enclosed 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 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"), "

a

\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]"), "

a\nb

", "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"), "

[\na

\n

]: b

", "should prefer setext headings over definition labels" ); assert_eq!( - micromark("[a]: b '\nc\n=\n'"), + to_html("[a]: b '\nc\n=\n'"), "

[a]: b '\nc

\n

'

", "should prefer setext headings over definition titles" ); assert_eq!( - micromark("[\n***\n]: b"), + to_html("[\n***\n]: b"), "

[

\n
\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
\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