From 246063fb7cd21a83beae5934f95b2795fb85df51 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Fri, 14 Oct 2022 10:49:28 +0200 Subject: Refactor to use default trait in tests --- tests/attention.rs | 12 +- tests/autolink.rs | 12 +- tests/block_quote.rs | 8 +- tests/character_escape.rs | 12 +- tests/character_reference.rs | 12 +- tests/code_fenced.rs | 14 +-- tests/code_indented.rs | 14 +-- tests/code_text.rs | 12 +- tests/definition.rs | 12 +- tests/frontmatter.rs | 6 +- tests/fuzz.rs | 16 +-- tests/gfm_autolink_literal.rs | 130 ++++++++++----------- tests/gfm_footnote.rs | 142 ++++++++++------------- tests/gfm_strikethrough.rs | 44 +++---- tests/gfm_table.rs | 184 +++++++++++++----------------- tests/gfm_tagfilter.rs | 16 +-- tests/gfm_task_list_item.rs | 22 ++-- tests/hard_break_escape.rs | 6 +- tests/hard_break_trailing.rs | 8 +- tests/heading_atx.rs | 8 +- tests/heading_setext.rs | 8 +- tests/html_flow.rs | 40 +++---- tests/html_text.rs | 12 +- tests/image.rs | 14 +-- tests/link_reference.rs | 21 ++-- tests/link_resource.rs | 8 +- tests/list.rs | 16 +-- tests/math_flow.rs | 6 +- tests/math_text.rs | 18 +-- tests/mdx_esm.rs | 4 +- tests/mdx_expression_flow.rs | 27 ++--- tests/mdx_expression_text.rs | 15 +-- tests/mdx_jsx_flow.rs | 26 ++--- tests/mdx_jsx_text.rs | 25 ++-- tests/mdx_swc.rs | 4 +- tests/misc_dangerous_html.rs | 4 +- tests/misc_default_line_ending.rs | 8 +- tests/misc_line_ending.rs | 4 +- tests/misc_tabs.rs | 4 +- tests/thematic_break.rs | 8 +- tests/xxx_mdx_plugin_recma_document.rs | 5 +- tests/xxx_mdx_plugin_recma_jsx_rewrite.rs | 5 +- 42 files changed, 429 insertions(+), 543 deletions(-) (limited to 'tests') diff --git a/tests/attention.rs b/tests/attention.rs index 1eef10d..d79432d 100644 --- a/tests/attention.rs +++ b/tests/attention.rs @@ -13,9 +13,9 @@ fn attention() -> Result<(), String> { compile: CompileOptions { allow_dangerous_html: true, allow_dangerous_protocol: true, - ..CompileOptions::default() + ..Default::default() }, - ..Options::default() + ..Default::default() }; // Rule 1. @@ -827,11 +827,11 @@ fn attention() -> Result<(), String> { parse: ParseOptions { constructs: Constructs { attention: false, - ..Constructs::default() + ..Default::default() }, - ..ParseOptions::default() + ..Default::default() }, - ..Options::default() + ..Default::default() } )?, "

*a*

", @@ -839,7 +839,7 @@ fn attention() -> Result<(), String> { ); assert_eq!( - to_mdast("a *alpha* b **bravo** c.", &ParseOptions::default())?, + to_mdast("a *alpha* b **bravo** c.", &Default::default())?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { children: vec![ diff --git a/tests/autolink.rs b/tests/autolink.rs index 1b20e08..64f94e9 100644 --- a/tests/autolink.rs +++ b/tests/autolink.rs @@ -13,9 +13,9 @@ fn autolink() -> Result<(), String> { compile: CompileOptions { allow_dangerous_html: true, allow_dangerous_protocol: true, - ..CompileOptions::default() + ..Default::default() }, - ..Options::default() + ..Default::default() }; assert_eq!( @@ -259,11 +259,11 @@ fn autolink() -> Result<(), String> { parse: ParseOptions { constructs: Constructs { autolink: false, - ..Constructs::default() + ..Default::default() }, - ..ParseOptions::default() + ..Default::default() }, - ..Options::default() + ..Default::default() } )?, "

<a@b.co>

", @@ -273,7 +273,7 @@ fn autolink() -> Result<(), String> { assert_eq!( to_mdast( "a b c.", - &ParseOptions::default() + &Default::default() )?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { diff --git a/tests/block_quote.rs b/tests/block_quote.rs index 970b82e..5d765e8 100644 --- a/tests/block_quote.rs +++ b/tests/block_quote.rs @@ -208,11 +208,11 @@ fn block_quote() -> Result<(), String> { parse: ParseOptions { constructs: Constructs { block_quote: false, - ..Constructs::default() + ..Default::default() }, - ..ParseOptions::default() + ..Default::default() }, - ..Options::default() + ..Default::default() } )?, "

> # a\n> b\n> c

", @@ -220,7 +220,7 @@ fn block_quote() -> Result<(), String> { ); assert_eq!( - to_mdast("> a", &ParseOptions::default())?, + to_mdast("> a", &Default::default())?, Node::Root(Root { children: vec![Node::BlockQuote(BlockQuote { children: vec![Node::Paragraph(Paragraph { diff --git a/tests/character_escape.rs b/tests/character_escape.rs index 0546269..41cc68d 100644 --- a/tests/character_escape.rs +++ b/tests/character_escape.rs @@ -13,9 +13,9 @@ fn character_escape() -> Result<(), String> { compile: CompileOptions { allow_dangerous_html: true, allow_dangerous_protocol: true, - ..CompileOptions::default() + ..Default::default() }, - ..Options::default() + ..Default::default() }; assert_eq!( @@ -93,11 +93,11 @@ fn character_escape() -> Result<(), String> { parse: ParseOptions { constructs: Constructs { character_escape: false, - ..Constructs::default() + ..Default::default() }, - ..ParseOptions::default() + ..Default::default() }, - ..Options::default() + ..Default::default() } )?, "

\\> a

", @@ -105,7 +105,7 @@ fn character_escape() -> Result<(), String> { ); assert_eq!( - to_mdast("a \\* b", &ParseOptions::default())?, + to_mdast("a \\* b", &Default::default())?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { children: vec![Node::Text(Text { diff --git a/tests/character_reference.rs b/tests/character_reference.rs index 0d72fff..ab253c4 100644 --- a/tests/character_reference.rs +++ b/tests/character_reference.rs @@ -55,9 +55,9 @@ fn character_reference() -> Result<(), String> { compile: CompileOptions { allow_dangerous_html: true, allow_dangerous_protocol: true, - ..CompileOptions::default() + ..Default::default() }, - ..Options::default() + ..Default::default() } )?, "", @@ -204,11 +204,11 @@ fn character_reference() -> Result<(), String> { parse: ParseOptions { constructs: Constructs { character_reference: false, - ..Constructs::default() + ..Default::default() }, - ..ParseOptions::default() + ..Default::default() }, - ..Options::default() + ..Default::default() } )?, "

&amp;

", @@ -216,7 +216,7 @@ fn character_reference() -> Result<(), String> { ); assert_eq!( - to_mdast("  & © Æ Ď\n¾ ℋ ⅆ\n∲ ≧̸\n# Ӓ Ϡ �\n" ആ ಫ", &ParseOptions::default())?, + to_mdast("  & © Æ Ď\n¾ ℋ ⅆ\n∲ ≧̸\n# Ӓ Ϡ �\n" ആ ಫ", &Default::default())?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { children: vec![Node::Text(Text { diff --git a/tests/code_fenced.rs b/tests/code_fenced.rs index e544ade..73bcb9a 100644 --- a/tests/code_fenced.rs +++ b/tests/code_fenced.rs @@ -269,11 +269,11 @@ fn code_fenced() -> Result<(), String> { parse: ParseOptions { constructs: Constructs { code_fenced: false, - ..Constructs::default() + ..Default::default() }, - ..ParseOptions::default() + ..Default::default() }, - ..Options::default() + ..Default::default() } )?, "

```

", @@ -283,7 +283,7 @@ fn code_fenced() -> Result<(), String> { assert_eq!( to_mdast( "```js extra\nconsole.log(1)\nconsole.log(2)\n```", - &ParseOptions::default() + &Default::default() )?, Node::Root(Root { children: vec![Node::Code(Code { @@ -298,7 +298,7 @@ fn code_fenced() -> Result<(), String> { ); assert_eq!( - to_mdast("```\nasd", &ParseOptions::default())?, + to_mdast("```\nasd", &Default::default())?, Node::Root(Root { children: vec![Node::Code(Code { lang: None, @@ -312,7 +312,7 @@ fn code_fenced() -> Result<(), String> { ); assert_eq!( - to_mdast("```\rasd\r```", &ParseOptions::default())?, + to_mdast("```\rasd\r```", &Default::default())?, Node::Root(Root { children: vec![Node::Code(Code { lang: None, @@ -326,7 +326,7 @@ fn code_fenced() -> Result<(), String> { ); assert_eq!( - to_mdast("```\r\nasd\r\n```", &ParseOptions::default())?, + to_mdast("```\r\nasd\r\n```", &Default::default())?, Node::Root(Root { children: vec![Node::Code(Code { lang: None, diff --git a/tests/code_indented.rs b/tests/code_indented.rs index 6545ed6..66046c4 100644 --- a/tests/code_indented.rs +++ b/tests/code_indented.rs @@ -127,11 +127,11 @@ fn code_indented() -> Result<(), String> { parse: ParseOptions { constructs: Constructs { code_indented: false, - ..Constructs::default() + ..Default::default() }, - ..ParseOptions::default() + ..Default::default() }, - ..Options::default() + ..Default::default() }; assert_eq!( @@ -177,13 +177,13 @@ fn code_indented() -> Result<(), String> { parse: ParseOptions { constructs: Constructs { code_indented: false, - ..Constructs::default() + ..Default::default() }, - ..ParseOptions::default() + ..Default::default() }, compile: CompileOptions { allow_dangerous_html: true, - ..CompileOptions::default() + ..Default::default() } } )?, @@ -206,7 +206,7 @@ fn code_indented() -> Result<(), String> { assert_eq!( to_mdast( "\tconsole.log(1)\n console.log(2)\n", - &ParseOptions::default() + &Default::default() )?, Node::Root(Root { children: vec![Node::Code(Code { diff --git a/tests/code_text.rs b/tests/code_text.rs index 2784398..482c46f 100644 --- a/tests/code_text.rs +++ b/tests/code_text.rs @@ -13,9 +13,9 @@ fn code_text() -> Result<(), String> { compile: CompileOptions { allow_dangerous_html: true, allow_dangerous_protocol: true, - ..CompileOptions::default() + ..Default::default() }, - ..Options::default() + ..Default::default() }; assert_eq!( @@ -170,11 +170,11 @@ fn code_text() -> Result<(), String> { parse: ParseOptions { constructs: Constructs { code_text: false, - ..Constructs::default() + ..Default::default() }, - ..ParseOptions::default() + ..Default::default() }, - ..Options::default() + ..Default::default() } )?, "

`a`

", @@ -182,7 +182,7 @@ fn code_text() -> Result<(), String> { ); assert_eq!( - to_mdast("a `alpha` b.", &ParseOptions::default())?, + to_mdast("a `alpha` b.", &Default::default())?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { children: vec![ diff --git a/tests/definition.rs b/tests/definition.rs index 5f9c286..46d9cf5 100644 --- a/tests/definition.rs +++ b/tests/definition.rs @@ -13,9 +13,9 @@ fn definition() -> Result<(), String> { compile: CompileOptions { allow_dangerous_html: true, allow_dangerous_protocol: true, - ..CompileOptions::default() + ..Default::default() }, - ..Options::default() + ..Default::default() }; assert_eq!( @@ -497,11 +497,11 @@ fn definition() -> Result<(), String> { parse: ParseOptions { constructs: Constructs { definition: false, - ..Constructs::default() + ..Default::default() }, - ..ParseOptions::default() + ..Default::default() }, - ..Options::default() + ..Default::default() } )?, "

[foo]: /url "title"

", @@ -509,7 +509,7 @@ fn definition() -> Result<(), String> { ); assert_eq!( - to_mdast("[a]: 'c'", &ParseOptions::default())?, + to_mdast("[a]: 'c'", &Default::default())?, Node::Root(Root { children: vec![Node::Definition(Definition { url: "b".into(), diff --git a/tests/frontmatter.rs b/tests/frontmatter.rs index b1380b6..7e647d9 100644 --- a/tests/frontmatter.rs +++ b/tests/frontmatter.rs @@ -13,11 +13,11 @@ fn frontmatter() -> Result<(), String> { parse: ParseOptions { constructs: Constructs { frontmatter: true, - ..Constructs::default() + ..Default::default() }, - ..ParseOptions::default() + ..Default::default() }, - ..Options::default() + ..Default::default() }; assert_eq!( diff --git a/tests/fuzz.rs b/tests/fuzz.rs index 819edf6..8d64ff2 100644 --- a/tests/fuzz.rs +++ b/tests/fuzz.rs @@ -1,5 +1,5 @@ extern crate markdown; -use markdown::{to_html, to_html_with_options, CompileOptions, Constructs, Options, ParseOptions}; +use markdown::{to_html, to_html_with_options, Options}; use pretty_assertions::assert_eq; #[test] @@ -13,19 +13,7 @@ fn fuzz() -> Result<(), String> { // The first link is stopped by the `+` (so it’s `a@b.c`), but the next // link overlaps it (`b.c+d@e.f`). assert_eq!( - to_html_with_options( - "a@b.c+d@e.f", - &Options { - parse: ParseOptions { - constructs: Constructs::gfm(), - ..ParseOptions::default() - }, - compile: CompileOptions { - gfm_tagfilter: true, - ..CompileOptions::default() - } - } - )?, + to_html_with_options("a@b.c+d@e.f", &Options::gfm())?, "

a@b.c+d@e.f

", "2: gfm: email autolink literals running into each other" ); diff --git a/tests/gfm_autolink_literal.rs b/tests/gfm_autolink_literal.rs index cdeecd3..cb38f29 100644 --- a/tests/gfm_autolink_literal.rs +++ b/tests/gfm_autolink_literal.rs @@ -3,20 +3,12 @@ use markdown::{ mdast::{Link, Node, Paragraph, Root, Text}, to_html, to_html_with_options, to_mdast, unist::Position, - Constructs, Options, ParseOptions, + Options, ParseOptions, }; use pretty_assertions::assert_eq; #[test] fn gfm_autolink_literal() -> Result<(), String> { - let gfm = Options { - parse: ParseOptions { - constructs: Constructs::gfm(), - ..ParseOptions::default() - }, - ..Options::default() - }; - assert_eq!( to_html("https://example.com"), "

https://example.com

", @@ -34,165 +26,165 @@ fn gfm_autolink_literal() -> Result<(), String> { ); assert_eq!( - to_html_with_options("https://example.com", &gfm)?, + to_html_with_options("https://example.com", &Options::gfm())?, "

https://example.com

", "should support protocol urls if enabled" ); assert_eq!( - to_html_with_options("www.example.com", &gfm)?, + to_html_with_options("www.example.com", &Options::gfm())?, "

www.example.com

", "should support www urls if enabled" ); assert_eq!( - to_html_with_options("user@example.com", &gfm)?, + to_html_with_options("user@example.com", &Options::gfm())?, "

user@example.com

", "should support email urls if enabled" ); assert_eq!( - to_html_with_options("[https://example.com](xxx)", &gfm)?, + to_html_with_options("[https://example.com](xxx)", &Options::gfm())?, "

https://example.com

", "should not link protocol urls in links" ); assert_eq!( - to_html_with_options("[www.example.com](xxx)", &gfm)?, + to_html_with_options("[www.example.com](xxx)", &Options::gfm())?, "

www.example.com

", "should not link www urls in links" ); assert_eq!( - to_html_with_options("[user@example.com](xxx)", &gfm)?, + to_html_with_options("[user@example.com](xxx)", &Options::gfm())?, "

user@example.com

", "should not link email urls in links" ); assert_eq!( - to_html_with_options("user@example.com", &gfm)?, + to_html_with_options("user@example.com", &Options::gfm())?, "

user@example.com

", "should support a closing paren at TLD (email)" ); assert_eq!( - to_html_with_options("www.a.)", &gfm)?, + to_html_with_options("www.a.)", &Options::gfm())?, "

www.a.)

", "should support a closing paren at TLD (www)" ); assert_eq!( - to_html_with_options("www.a b", &gfm)?, + to_html_with_options("www.a b", &Options::gfm())?, "

www.a b

", "should support no TLD" ); assert_eq!( - to_html_with_options("www.a/b c", &gfm)?, + to_html_with_options("www.a/b c", &Options::gfm())?, "

www.a/b c

", "should support a path instead of TLD" ); assert_eq!( - to_html_with_options("www.�a", &gfm)?, + to_html_with_options("www.�a", &Options::gfm())?, "

www.�a

", "should support a replacement character in a domain" ); assert_eq!( - to_html_with_options("http://點看.com", &gfm)?, + to_html_with_options("http://點看.com", &Options::gfm())?, "

http://點看.com

", "should support non-ascii characters in a domain (http)" ); assert_eq!( - to_html_with_options("www.點看.com", &gfm)?, + to_html_with_options("www.點看.com", &Options::gfm())?, "

www.點看.com

", "should support non-ascii characters in a domain (www)" ); assert_eq!( - to_html_with_options("點看@example.com", &gfm)?, + to_html_with_options("點看@example.com", &Options::gfm())?, "

點看@example.com

", "should *not* support non-ascii characters in atext (email)" ); assert_eq!( - to_html_with_options("example@點看.com", &gfm)?, + to_html_with_options("example@點看.com", &Options::gfm())?, "

example@點看.com

", "should *not* support non-ascii characters in a domain (email)" ); assert_eq!( - to_html_with_options("www.a.com/點看", &gfm)?, + to_html_with_options("www.a.com/點看", &Options::gfm())?, "

www.a.com/點看

", "should support non-ascii characters in a path" ); assert_eq!( - to_html_with_options("www.-a.b", &gfm)?, + to_html_with_options("www.-a.b", &Options::gfm())?, "

www.-a.b

", "should support a dash to start a domain" ); assert_eq!( - to_html_with_options("www.$", &gfm)?, + to_html_with_options("www.$", &Options::gfm())?, "

www.$

", "should support a dollar as a domain name" ); assert_eq!( - to_html_with_options("www.a..b.c", &gfm)?, + to_html_with_options("www.a..b.c", &Options::gfm())?, "

www.a..b.c

", "should support adjacent dots in a domain name" ); assert_eq!( - to_html_with_options("www.a&a;", &gfm)?, + to_html_with_options("www.a&a;", &Options::gfm())?, "

www.a&a;

", "should support named character references in domains" ); assert_eq!( - to_html_with_options("https://a.bc/d/e/).", &gfm)?, + to_html_with_options("https://a.bc/d/e/).", &Options::gfm())?, "

https://a.bc/d/e/).

", "should support a closing paren and period after a path" ); assert_eq!( - to_html_with_options("https://a.bc/d/e/.)", &gfm)?, + to_html_with_options("https://a.bc/d/e/.)", &Options::gfm())?, "

https://a.bc/d/e/.)

", "should support a period and closing paren after a path" ); assert_eq!( - to_html_with_options("https://a.bc).", &gfm)?, + to_html_with_options("https://a.bc).", &Options::gfm())?, "

https://a.bc).

", "should support a closing paren and period after a domain" ); assert_eq!( - to_html_with_options("https://a.bc.)", &gfm)?, + to_html_with_options("https://a.bc.)", &Options::gfm())?, "

https://a.bc.)

", "should support a period and closing paren after a domain" ); assert_eq!( - to_html_with_options("https://a.bc).d", &gfm)?, + to_html_with_options("https://a.bc).d", &Options::gfm())?, "

https://a.bc).d

", "should support a closing paren and period in a path" ); assert_eq!( - to_html_with_options("https://a.bc.)d", &gfm)?, + to_html_with_options("https://a.bc.)d", &Options::gfm())?, "

https://a.bc.)d

", "should support a period and closing paren in a path" ); assert_eq!( - to_html_with_options("https://a.bc/))d", &gfm)?, + to_html_with_options("https://a.bc/))d", &Options::gfm())?, "

https://a.bc/))d

", "should support two closing parens in a path" ); assert_eq!( - to_html_with_options("ftp://a/b/c.txt", &gfm)?, + to_html_with_options("ftp://a/b/c.txt", &Options::gfm())?, "

ftp://a/b/c.txt

", "should not support ftp links" ); @@ -201,19 +193,19 @@ fn gfm_autolink_literal() -> Result<(), String> { // Fixing it would mean deviating from `cmark-gfm`: // Source: . // assert_eq!( - // to_html_with_options(",www.example.com", &gfm)?, + // to_html_with_options(",www.example.com", &Options::gfm())?, // "

www.example.com

", // "should support www links after Unicode punctuation", // ); assert_eq!( - to_html_with_options(",https://example.com", &gfm)?, + to_html_with_options(",https://example.com", &Options::gfm())?, "

https://example.com

", "should support http links after Unicode punctuation" ); assert_eq!( - to_html_with_options(",example@example.com", &gfm)?, + to_html_with_options(",example@example.com", &Options::gfm())?, "

example@example.com

", "should support email links after Unicode punctuation" ); @@ -221,14 +213,14 @@ fn gfm_autolink_literal() -> Result<(), String> { assert_eq!( to_html_with_options( "http://user:password@host:port/path?key=value#fragment", - &gfm + &Options::gfm() )?, "

http://user:password@host:port/path?key=value#fragment

", "should not link character reference for `:`" ); assert_eq!( - to_html_with_options("http://example.com/abhttp://example.com/ab<cd

", "should stop domains/paths at `<`" ); @@ -259,7 +251,7 @@ xmpp:scyther@pokemon.com/message xmpp:scyther@pokemon.com/message. Email me at:scyther@pokemon.com"###, - &gfm + &Options::gfm() )?, r###"

mailto:scyther@pokemon.com

This is a mailto:scyther@pokemon.com

@@ -305,7 +297,7 @@ a www.example.com&. b a www.example.com& b "###, - &gfm + &Options::gfm() )?, r###"

a www.example.com&xxx;b c

a www.example.com&xxx;. b

@@ -352,7 +344,7 @@ a www.example.com& b ![ contact@example.com ](#) "###, - &gfm + &Options::gfm() )?, r###"

[ www.example.com

[ https://example.com

@@ -399,7 +391,7 @@ www.example.com/?q=a(business))) (www.example.com/?q=a(business)". "###, - &gfm + &Options::gfm() )?, r###"

www.example.com/?=a(b)cccccc

www.example.com/?=a(b(c)ccccc

@@ -544,7 +536,7 @@ Can contain an underscore followed by a period: aaa@a.b_.c [link]() should still be expanded. "###, - &gfm + &Options::gfm() )?, r###"

Literal autolinks

WWW autolinks

@@ -648,7 +640,7 @@ H5. [[]]www.a.com©b "###, - &gfm + &Options::gfm() )?, r###"

H0.

[https://a.com&copy;b

@@ -724,7 +716,7 @@ Autolink literal after image. ![a]() www.a.com ![a]() a@b.c -"###, &gfm)?, +"###, &Options::gfm())?, r###"

Image start.

![https://a.com

![http://a.com

@@ -866,7 +858,7 @@ Autolink literal after link. [a]() www.a.com [a]() a@b.c -"###, &gfm)?, +"###, &Options::gfm())?, r###"

Link start.

[https://a.com

[http://a.com

@@ -998,7 +990,7 @@ www.a&b} www.a&b~ "###, - &gfm + &Options::gfm() )?, r###"

“character reference”

www.a&b (space)

@@ -1109,7 +1101,7 @@ www.a#| www.a#} www.a#~ -"###, &gfm)?, +"###, &Options::gfm())?, r###"

“character reference”

www.a&#35 (space)

www.a&#35!

@@ -1181,7 +1173,7 @@ react@0.0.0-experimental-aae83a4b9 [ react@0.0.0-experimental-aae83a4b9 "###, - &gfm + &Options::gfm() )?, r###"

a@0.0

a@0.b

@@ -1274,7 +1266,7 @@ http://a} http://a~ "###, - &gfm + &Options::gfm() )?, r###"

httpshhh? (2)

http://a (space)

@@ -1387,7 +1379,7 @@ http://} http://~ "###, - &gfm + &Options::gfm() )?, r###"

httpshhh? (1)

http:// (space)

@@ -1500,7 +1492,7 @@ http://a/b} http://a/b~ "###, - &gfm + &Options::gfm() )?, r###"

httpshhh? (4)

http://a/b (space)

@@ -1613,7 +1605,7 @@ http://a/} http://a/~ "###, - &gfm + &Options::gfm() )?, r###"

httpshhh? (3)

http://a/ (space)

@@ -1668,7 +1660,7 @@ www.example.com/a&bogus; www.example.com/a\. "###, - &gfm + &Options::gfm() )?, r###"

www.example.com/a©

www.example.com/a©

@@ -1752,7 +1744,7 @@ www.a/b&c} www.a/b&c~ "###, - &gfm + &Options::gfm() )?, r###"

“character reference”

www.a/b&c (space)

@@ -1865,7 +1857,7 @@ www.a/b#} www.a/b#~ "###, - &gfm + &Options::gfm() )?, r###"

“character reference”

www.a/b&#35 (space)

@@ -1950,7 +1942,7 @@ http://a.com#d]() www.a.com#d]() "###, - &gfm + &Options::gfm() )?, r###"

In autolink literal path or link end?

https://a.com/d

@@ -2023,7 +2015,7 @@ Some non-ascii: 中noreply@example.com, 中http://example.com, 中https://exampl Some more non-ascii: 🤷‍noreply@example.com, 🤷‍http://example.com, 🤷‍https://example.com, 🤷‍www.example.com "###, - &gfm + &Options::gfm() )?, r###"

Last non-markdown ASCII whitespace (FF): noreply@example.com, http://example.com, https://example.com, www.example.com

Last non-whitespace ASCII control (US): noreply@example.com, http://example.com, https://example.com, www.example.com

@@ -2130,7 +2122,7 @@ See `https://github.com/remarkjs/remark/discussions/678`. [asd] ,https://github.com "###, - &gfm + &Options::gfm() )?, r###"

HTTP

https://a.b can start after EOF

@@ -2250,7 +2242,7 @@ www.a} www.a~ "###, - &gfm + &Options::gfm() )?, r###"

wwwtf 2?

www.a (space)

@@ -2363,7 +2355,7 @@ www.a.} www.a.~ "###, - &gfm + &Options::gfm() )?, r###"

wwwtf 5?

www.a. (space)

@@ -2476,7 +2468,7 @@ www.} www.~ "###, - &gfm + &Options::gfm() )?, r###"

wwwtf?

www. (space)

@@ -2589,7 +2581,7 @@ www.a/b} www.a/b~ "###, - &gfm + &Options::gfm() )?, r###"

wwwtf? (4)

www.a/b (space)

@@ -2702,7 +2694,7 @@ www.a/} www.a/~ "###, - &gfm + &Options::gfm() )?, r###"

wwwtf? (3)

www.a/ (space)

@@ -2746,7 +2738,7 @@ www.a/~ assert_eq!( to_mdast( "a https://alpha.com b bravo@charlie.com c www.delta.com d xmpp:echo@foxtrot.com e mailto:golf@hotel.com f.", - &gfm.parse + &ParseOptions::gfm() )?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { diff --git a/tests/gfm_footnote.rs b/tests/gfm_footnote.rs index f5ae0cb..e036857 100644 --- a/tests/gfm_footnote.rs +++ b/tests/gfm_footnote.rs @@ -3,20 +3,12 @@ use markdown::{ mdast::{FootnoteDefinition, FootnoteReference, Node, Paragraph, Root, Text}, to_html, to_html_with_options, to_mdast, unist::Position, - CompileOptions, Constructs, Options, ParseOptions, + CompileOptions, Options, ParseOptions, }; use pretty_assertions::assert_eq; #[test] fn gfm_footnote() -> Result<(), String> { - let gfm = Options { - parse: ParseOptions { - constructs: Constructs::gfm(), - ..ParseOptions::default() - }, - ..Options::default() - }; - assert_eq!( to_html("A call.[^a]\n\n[^a]: whatevs"), "

A call.^a

\n", @@ -24,7 +16,7 @@ fn gfm_footnote() -> Result<(), String> { ); assert_eq!( - to_html_with_options("A call.[^a]\n\n[^a]: whatevs", &gfm)?, + to_html_with_options("A call.[^a]\n\n[^a]: whatevs", &Options::gfm())?, "

A call.1

Footnotes

    @@ -41,14 +33,11 @@ fn gfm_footnote() -> Result<(), String> { to_html_with_options( "Noot.[^a]\n\n[^a]: dingen", &Options { - parse: ParseOptions { - constructs: Constructs::gfm(), - ..ParseOptions::default() - }, + parse: ParseOptions::gfm(), compile: CompileOptions { - gfm_footnote_label: Some("Voetnoten".into()), - gfm_footnote_back_label: Some("Terug naar de inhoud".into()), - ..CompileOptions::default() + gfm_footnote_label: Some("Voetnoten".into()), + gfm_footnote_back_label: Some("Terug naar de inhoud".into()), + ..CompileOptions::gfm() } } )?, @@ -68,13 +57,10 @@ fn gfm_footnote() -> Result<(), String> { to_html_with_options( "[^a]\n\n[^a]: b", &Options { - parse: ParseOptions { - constructs: Constructs::gfm(), - ..ParseOptions::default() - }, + parse: ParseOptions::gfm(), compile: CompileOptions { - gfm_footnote_label_tag_name: Some("h1".into()), - ..CompileOptions::default() + gfm_footnote_label_tag_name: Some("h1".into()), + ..CompileOptions::gfm() } } )?, @@ -94,13 +80,10 @@ fn gfm_footnote() -> Result<(), String> { to_html_with_options( "[^a]\n\n[^a]: b", &Options { - parse: ParseOptions { - constructs: Constructs::gfm(), - ..ParseOptions::default() - }, + parse: ParseOptions::gfm(), compile: CompileOptions { - gfm_footnote_label_attributes: Some("class=\"footnote-heading\"".into()), - ..CompileOptions::default() + gfm_footnote_label_attributes: Some("class=\"footnote-heading\"".into()), + ..CompileOptions::gfm() } } )?, @@ -120,13 +103,10 @@ fn gfm_footnote() -> Result<(), String> { to_html_with_options( "[^a]\n\n[^a]: b", &Options { - parse: ParseOptions { - constructs: Constructs::gfm(), - ..ParseOptions::default() - }, + parse: ParseOptions::gfm(), compile: CompileOptions { gfm_footnote_clobber_prefix: Some("".into()), - ..CompileOptions::default() + ..CompileOptions::gfm() } } )?, @@ -143,19 +123,19 @@ fn gfm_footnote() -> Result<(), String> { ); assert_eq!( - to_html_with_options("A paragraph.\n\n[^a]: whatevs", &gfm)?, + to_html_with_options("A paragraph.\n\n[^a]: whatevs", &Options::gfm())?, "

    A paragraph.

    \n", "should ignore definitions w/o calls" ); assert_eq!( - to_html_with_options("a[^b]", &gfm)?, + to_html_with_options("a[^b]", &Options::gfm())?, "

    a[^b]

    ", "should ignore calls w/o definitions" ); assert_eq!( - to_html_with_options("a[^b]\n\n[^b]: c\n[^b]: d", &gfm)?, + to_html_with_options("a[^b]\n\n[^b]: c\n[^b]: d", &Options::gfm())?, "

    a1

    Footnotes

      @@ -169,7 +149,7 @@ fn gfm_footnote() -> Result<(), String> { ); assert_eq!( - to_html_with_options("a[^b], c[^b]\n\n[^b]: d", &gfm)?, + to_html_with_options("a[^b], c[^b]\n\n[^b]: d", &Options::gfm())?, "

      a1, c1

      Footnotes

        @@ -183,32 +163,32 @@ fn gfm_footnote() -> Result<(), String> { ); assert_eq!( - to_html_with_options("![^a](b)", &gfm)?, + to_html_with_options("![^a](b)", &Options::gfm())?, "

        !^a

        ", "should not support images starting w/ `^` (but see it as a link?!, 1)" ); assert_eq!( - to_html_with_options("![^a][b]\n\n[b]: c", &gfm)?, + to_html_with_options("![^a][b]\n\n[b]: c", &Options::gfm())?, "

        !^a

        \n", "should not support images starting w/ `^` (but see it as a link?!, 2)" ); assert_eq!( - to_html_with_options("[^]()", &gfm)?, + to_html_with_options("[^]()", &Options::gfm())?, "

        ^

        ", "should support an empty link with caret" ); assert_eq!( - to_html_with_options("![^]()", &gfm)?, + to_html_with_options("![^]()", &Options::gfm())?, "

        !^

        ", "should support an empty image with caret (as link)" ); // assert_eq!( - to_html_with_options("Call.[^a\\+b].\n\n[^a\\+b]: y", &gfm)?, + to_html_with_options("Call.[^a\\+b].\n\n[^a\\+b]: y", &Options::gfm())?, "

        Call.1.

        Footnotes

          @@ -222,7 +202,7 @@ fn gfm_footnote() -> Result<(), String> { ); assert_eq!( - to_html_with_options("Call.[^a©b].\n\n[^a©b]: y", &gfm)?, + to_html_with_options("Call.[^a©b].\n\n[^a©b]: y", &Options::gfm())?, "

          Call.1.

          Footnotes

            @@ -238,7 +218,7 @@ fn gfm_footnote() -> Result<(), String> { // // assert_eq!( - to_html_with_options("Call.[^a\\]b].\n\n[^a\\]b]: y", &gfm)?, + to_html_with_options("Call.[^a\\]b].\n\n[^a\\]b]: y", &Options::gfm())?, "

            Call.1.

            Footnotes

              @@ -252,7 +232,7 @@ fn gfm_footnote() -> Result<(), String> { ); assert_eq!( - to_html_with_options("Call.[^a[b].\n\n[^a[b]: y", &gfm)?, + to_html_with_options("Call.[^a[b].\n\n[^a[b]: y", &Options::gfm())?, "

              Call.1.

              Footnotes

                @@ -266,19 +246,19 @@ fn gfm_footnote() -> Result<(), String> { ); assert_eq!( - to_html_with_options("Call.[^a\\+b].\n\n[^a+b]: y", &gfm)?, + to_html_with_options("Call.[^a\\+b].\n\n[^a+b]: y", &Options::gfm())?, "

                Call.[^a+b].

                \n", "should match calls to definitions on the source of the label, not on resolved escapes" ); assert_eq!( - to_html_with_options("Call.[^a[b].\n\n[^a\\[b]: y", &gfm)?, + to_html_with_options("Call.[^a[b].\n\n[^a\\[b]: y", &Options::gfm())?, "

                Call.[^a[b].

                \n", "should match calls to definitions on the source of the label, not on resolved references" ); assert_eq!( - to_html_with_options("[^1].\n\n[^1]: a\nb", &gfm)?, + to_html_with_options("[^1].\n\n[^1]: a\nb", &Options::gfm())?, "

                1.

                Footnotes

                  @@ -293,7 +273,7 @@ b [^1]: a\nb", &gfm)?, + to_html_with_options("[^1].\n\n> [^1]: a\nb", &Options::gfm())?, "

                  1.

                  @@ -310,7 +290,7 @@ b [^1]: a\n> b", &gfm)?, + to_html_with_options("[^1].\n\n> [^1]: a\n> b", &Options::gfm())?, "

                  1.

                  @@ -327,7 +307,7 @@ b b", &gfm)?, + to_html_with_options("[^1].\n\n[^1]: a\n\n > b", &Options::gfm())?, "

                  1.

                  Footnotes

                    @@ -348,7 +328,7 @@ b Call.1.

                    Footnotes

                      @@ -364,7 +344,7 @@ b Call.[^a{}].

                      \n

                      [^a{}]: y

                      ", max, max), "should not support 1000 characters in a call / definition" @@ -373,7 +353,7 @@ b
                      1

                      Footnotes

                      @@ -399,7 +379,7 @@ a![^1] [^1]: b [i]: c"###, - &gfm + &Options::gfm() )?, r###"

                      ai a!i @@ -419,7 +399,7 @@ a!a![^1]

                      ", "should match bang/caret interplay (undefined) like GitHub" ); @@ -430,7 +410,7 @@ a!a!1

                      Footnotes

                      @@ -469,7 +449,7 @@ even another caret. [^^]: caret "###, - &gfm + &Options::gfm() )?, r###"

                      Calls may not be empty: ^.

                      Calls cannot contain whitespace only: ^ .

                      @@ -527,7 +507,7 @@ Some calls.[^ w][^x ][^y][^z] [^x ]: # z "###, - &gfm + &Options::gfm() )?, r###"

                      [^c d]: # e

                      [^f g]: # h

                      @@ -595,7 +575,7 @@ j], [^ l], [^m ]

                      [^![image](#)]: a "###, - &gfm + &Options::gfm() )?, // Note: // * GH does not support colons. @@ -654,7 +634,7 @@ j], [^ l], [^m ]

                      More. [^4]: Directly after a list item. "###, - &gfm + &Options::gfm() )?, r###"

                      Call1234

                      @@ -711,7 +691,7 @@ j], [^ l], [^m ]

                      - list "###, - &gfm + &Options::gfm() )?, r###"

                      1234

                      Heading

                      @@ -768,7 +748,7 @@ Lazy? Lazy! "###, - &gfm + &Options::gfm() )?, r###"

                      Call12345.

                      Lazy?

                      @@ -824,7 +804,7 @@ Lazy! [^10]:- - - kilo "###, - &gfm + &Options::gfm() )?, r###"

                      Note!1234567891011

                      Footnotes

                      @@ -897,7 +877,7 @@ indented delta Call11

                      Footnotes

                      @@ -919,7 +899,7 @@ indented delta Call1

                      Footnotes

                      @@ -961,7 +941,7 @@ indented delta emphasis1

                      strong2

                      @@ -998,7 +978,7 @@ indented delta What are these!1, !2[], and ![this]3.

                      Footnotes

                      @@ -1040,7 +1020,7 @@ indented delta 123456

                      Heading

                      @@ -1093,7 +1073,7 @@ indented delta What are these1, 2[], and [this]3.

                      Footnotes

                      @@ -1143,7 +1123,7 @@ indented delta 1234

                      Heading

                      @@ -1205,7 +1185,7 @@ indented delta 1234

                      Footnotes

                      @@ -1254,7 +1234,7 @@ more code [^3]: [^4]: Paragraph "###, - &gfm + &Options::gfm() )?, r###"

                      Note!1234