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/attention.rs | 272 ++++++++++++++++++++++++++--------------------------- 1 file changed, 136 insertions(+), 136 deletions(-) (limited to 'tests/attention.rs') diff --git a/tests/attention.rs b/tests/attention.rs index e627c4d..1eef10d 100644 --- a/tests/attention.rs +++ b/tests/attention.rs @@ -1,7 +1,7 @@ -extern crate micromark; -use micromark::{ +extern crate markdown; +use markdown::{ mdast::{Emphasis, Node, Paragraph, Root, Strong, Text}, - micromark, micromark_to_mdast, micromark_with_options, + to_html, to_html_with_options, to_mdast, unist::Position, CompileOptions, Constructs, Options, ParseOptions, }; @@ -20,265 +20,265 @@ fn attention() -> Result<(), String> { // Rule 1. assert_eq!( - micromark("*foo bar*"), + to_html("*foo bar*"), "

foo bar

", "should support emphasis w/ `*`" ); assert_eq!( - micromark("a * foo bar*"), + to_html("a * foo bar*"), "

a * foo bar*

", "should not support emphasis if the opening is not left flanking (1)" ); assert_eq!( - micromark("a*\"foo\"*"), + to_html("a*\"foo\"*"), "

a*"foo"*

", "should not support emphasis if the opening is not left flanking (2b)" ); assert_eq!( - micromark("* a *"), + to_html("* a *"), "

* a *

", "should not support emphasis unicode whitespace either" ); assert_eq!( - micromark("foo*bar*"), + to_html("foo*bar*"), "

foobar

", "should support intraword emphasis w/ `*` (1)" ); assert_eq!( - micromark("5*6*78"), + to_html("5*6*78"), "

5678

", "should support intraword emphasis w/ `*` (2)" ); // Rule 2. assert_eq!( - micromark("_foo bar_"), + to_html("_foo bar_"), "

foo bar

", "should support emphasis w/ `_`" ); assert_eq!( - micromark("_ foo bar_"), + to_html("_ foo bar_"), "

_ foo bar_

", "should not support emphasis if the opening is followed by whitespace" ); assert_eq!( - micromark("a_\"foo\"_"), + to_html("a_\"foo\"_"), "

a_"foo"_

", "should not support emphasis if the opening is preceded by something else and followed by punctuation" ); assert_eq!( - micromark("foo_bar_"), + to_html("foo_bar_"), "

foo_bar_

", "should not support intraword emphasis (1)" ); assert_eq!( - micromark("5_6_78"), + to_html("5_6_78"), "

5_6_78

", "should not support intraword emphasis (2)" ); assert_eq!( - micromark("пристаням_стремятся_"), + to_html("пристаням_стремятся_"), "

пристаням_стремятся_

", "should not support intraword emphasis (3)" ); assert_eq!( - micromark("aa_\"bb\"_cc"), + to_html("aa_\"bb\"_cc"), "

aa_"bb"_cc

", "should not support emphasis if the opening is right flanking and the closing is left flanking" ); assert_eq!( - micromark("foo-_(bar)_"), + to_html("foo-_(bar)_"), "

foo-(bar)

", "should support emphasis if the opening is both left and right flanking, if it’s preceded by punctuation" ); // Rule 3. assert_eq!( - micromark("_foo*"), + to_html("_foo*"), "

_foo*

", "should not support emphasis if opening and closing markers don’t match" ); assert_eq!( - micromark("*foo bar *"), + to_html("*foo bar *"), "

*foo bar *

", "should not support emphasis w/ `*` if the closing markers are preceded by whitespace" ); assert_eq!( - micromark("*foo bar\n*"), + to_html("*foo bar\n*"), "

*foo bar\n*

", "should not support emphasis w/ `*` if the closing markers are preceded by a line break (also whitespace)" ); assert_eq!( - micromark("*(*foo)"), + to_html("*(*foo)"), "

*(*foo)

", "should not support emphasis w/ `*` if the closing markers are not right flanking" ); assert_eq!( - micromark("*(*foo*)*"), + to_html("*(*foo*)*"), "

(foo)

", "should support nested emphasis" ); // Rule 4. assert_eq!( - micromark("_foo bar _"), + to_html("_foo bar _"), "

_foo bar _

", "should not support emphasis if the closing `_` is preceded by whitespace" ); assert_eq!( - micromark("_(_foo)"), + to_html("_(_foo)"), "

_(_foo)

", "should not support emphasis w/ `_` if the closing markers are not right flanking" ); assert_eq!( - micromark("_(_foo_)_"), + to_html("_(_foo_)_"), "

(foo)

", "should support nested emphasis w/ `_`" ); assert_eq!( - micromark("_foo_bar"), + to_html("_foo_bar"), "

_foo_bar

", "should not support intraword emphasis w/ `_` (1)" ); assert_eq!( - micromark("_пристаням_стремятся"), + to_html("_пристаням_стремятся"), "

_пристаням_стремятся

", "should not support intraword emphasis w/ `_` (2)" ); assert_eq!( - micromark("_foo_bar_baz_"), + to_html("_foo_bar_baz_"), "

foo_bar_baz

", "should not support intraword emphasis w/ `_` (3)" ); assert_eq!( - micromark("_(bar)_."), + to_html("_(bar)_."), "

(bar).

", "should support emphasis if the opening is both left and right flanking, if it’s followed by punctuation" ); // Rule 5. assert_eq!( - micromark("**foo bar**"), + to_html("**foo bar**"), "

foo bar

", "should support strong emphasis" ); assert_eq!( - micromark("** foo bar**"), + to_html("** foo bar**"), "

** foo bar**

", "should not support strong emphasis if the opening is followed by whitespace" ); assert_eq!( - micromark("a**\"foo\"**"), + to_html("a**\"foo\"**"), "

a**"foo"**

", "should not support strong emphasis if the opening is preceded by something else and followed by punctuation" ); assert_eq!( - micromark("foo**bar**"), + to_html("foo**bar**"), "

foobar

", "should support strong intraword emphasis" ); // Rule 6. assert_eq!( - micromark("__foo bar__"), + to_html("__foo bar__"), "

foo bar

", "should support strong emphasis w/ `_`" ); assert_eq!( - micromark("__ foo bar__"), + to_html("__ foo bar__"), "

__ foo bar__

", "should not support strong emphasis if the opening is followed by whitespace" ); assert_eq!( - micromark("__\nfoo bar__"), + to_html("__\nfoo bar__"), "

__\nfoo bar__

", "should not support strong emphasis if the opening is followed by a line ending (also whitespace)" ); assert_eq!( - micromark("a__\"foo\"__"), + to_html("a__\"foo\"__"), "

a__"foo"__

", "should not support strong emphasis if the opening is preceded by something else and followed by punctuation" ); assert_eq!( - micromark("foo__bar__"), + to_html("foo__bar__"), "

foo__bar__

", "should not support strong intraword emphasis w/ `_` (1)" ); assert_eq!( - micromark("5__6__78"), + to_html("5__6__78"), "

5__6__78

", "should not support strong intraword emphasis w/ `_` (2)" ); assert_eq!( - micromark("пристаням__стремятся__"), + to_html("пристаням__стремятся__"), "

пристаням__стремятся__

", "should not support strong intraword emphasis w/ `_` (3)" ); assert_eq!( - micromark("__foo, __bar__, baz__"), + to_html("__foo, __bar__, baz__"), "

foo, bar, baz

", "should support nested strong emphasis" ); assert_eq!( - micromark("foo-__(bar)__"), + to_html("foo-__(bar)__"), "

foo-(bar)

", "should support strong emphasis if the opening is both left and right flanking, if it’s preceded by punctuation" ); // Rule 7. assert_eq!( - micromark("**foo bar **"), + to_html("**foo bar **"), "

**foo bar **

", "should not support strong emphasis w/ `*` if the closing is preceded by whitespace" ); assert_eq!( - micromark("**(**foo)"), + to_html("**(**foo)"), "

**(**foo)

", "should not support strong emphasis w/ `*` if the closing is preceded by punctuation and followed by something else" ); assert_eq!( - micromark("*(**foo**)*"), + to_html("*(**foo**)*"), "

(foo)

", "should support strong emphasis in emphasis" ); assert_eq!( - micromark( + to_html( "**Gomphocarpus (*Gomphocarpus physocarpus*, syn.\n*Asclepias physocarpa*)**" ), "

Gomphocarpus (Gomphocarpus physocarpus, syn.\nAsclepias physocarpa)

", @@ -286,542 +286,542 @@ fn attention() -> Result<(), String> { ); assert_eq!( - micromark("**foo \"*bar*\" foo**"), + to_html("**foo \"*bar*\" foo**"), "

foo "bar" foo

", "should support emphasis in strong emphasis (2)" ); assert_eq!( - micromark("**foo**bar"), + to_html("**foo**bar"), "

foobar

", "should support strong intraword emphasis" ); // Rule 8. assert_eq!( - micromark("__foo bar __"), + to_html("__foo bar __"), "

__foo bar __

", "should not support strong emphasis w/ `_` if the closing is preceded by whitespace" ); assert_eq!( - micromark("__(__foo)"), + to_html("__(__foo)"), "

__(__foo)

", "should not support strong emphasis w/ `_` if the closing is preceded by punctuation and followed by something else" ); assert_eq!( - micromark("_(__foo__)_"), + to_html("_(__foo__)_"), "

(foo)

", "should support strong emphasis w/ `_` in emphasis" ); assert_eq!( - micromark("__foo__bar"), + to_html("__foo__bar"), "

__foo__bar

", "should not support strong intraword emphasis w/ `_` (1)" ); assert_eq!( - micromark("__пристаням__стремятся"), + to_html("__пристаням__стремятся"), "

__пристаням__стремятся

", "should not support strong intraword emphasis w/ `_` (2)" ); assert_eq!( - micromark("__foo__bar__baz__"), + to_html("__foo__bar__baz__"), "

foo__bar__baz

", "should not support strong intraword emphasis w/ `_` (3)" ); assert_eq!( - micromark("__(bar)__."), + to_html("__(bar)__."), "

(bar).

", "should support strong emphasis if the opening is both left and right flanking, if it’s followed by punctuation" ); // Rule 9. assert_eq!( - micromark("*foo [bar](/url)*"), + to_html("*foo [bar](/url)*"), "

foo bar

", "should support content in emphasis" ); assert_eq!( - micromark("*foo\nbar*"), + to_html("*foo\nbar*"), "

foo\nbar

", "should support line endings in emphasis" ); assert_eq!( - micromark("_foo __bar__ baz_"), + to_html("_foo __bar__ baz_"), "

foo bar baz

", "should support nesting emphasis and strong (1)" ); assert_eq!( - micromark("_foo _bar_ baz_"), + to_html("_foo _bar_ baz_"), "

foo bar baz

", "should support nesting emphasis and strong (2)" ); assert_eq!( - micromark("__foo_ bar_"), + to_html("__foo_ bar_"), "

foo bar

", "should support nesting emphasis and strong (3)" ); assert_eq!( - micromark("*foo *bar**"), + to_html("*foo *bar**"), "

foo bar

", "should support nesting emphasis and strong (4)" ); assert_eq!( - micromark("*foo **bar** baz*"), + to_html("*foo **bar** baz*"), "

foo bar baz

", "should support nesting emphasis and strong (5)" ); assert_eq!( - micromark("*foo**bar**baz*"), + to_html("*foo**bar**baz*"), "

foobarbaz

", "should support nesting emphasis and strong (6)" ); assert_eq!( - micromark("*foo**bar*"), + to_html("*foo**bar*"), "

foo**bar

", "should not support adjacent emphasis in certain cases" ); assert_eq!( - micromark("***foo** bar*"), + to_html("***foo** bar*"), "

foo bar

", "complex (1)" ); assert_eq!( - micromark("*foo **bar***"), + to_html("*foo **bar***"), "

foo bar

", "complex (2)" ); assert_eq!( - micromark("*foo**bar***"), + to_html("*foo**bar***"), "

foobar

", "complex (3)" ); assert_eq!( - micromark("foo***bar***baz"), + to_html("foo***bar***baz"), "

foobarbaz

", "complex (a)" ); assert_eq!( - micromark("foo******bar*********baz"), + to_html("foo******bar*********baz"), "

foobar***baz

", "complex (b)" ); assert_eq!( - micromark("*foo **bar *baz* bim** bop*"), + to_html("*foo **bar *baz* bim** bop*"), "

foo bar baz bim bop

", "should support indefinite nesting of emphasis (1)" ); assert_eq!( - micromark("*foo [*bar*](/url)*"), + to_html("*foo [*bar*](/url)*"), "

foo bar

", "should support indefinite nesting of emphasis (2)" ); assert_eq!( - micromark("** is not an empty emphasis"), + to_html("** is not an empty emphasis"), "

** is not an empty emphasis

", "should not support empty emphasis" ); assert_eq!( - micromark("**** is not an empty emphasis"), + to_html("**** is not an empty emphasis"), "

**** is not an empty emphasis

", "should not support empty strong emphasis" ); // Rule 10. assert_eq!( - micromark("**foo [bar](/url)**"), + to_html("**foo [bar](/url)**"), "

foo bar

", "should support content in strong emphasis" ); assert_eq!( - micromark("**foo\nbar**"), + to_html("**foo\nbar**"), "

foo\nbar

", "should support line endings in emphasis" ); assert_eq!( - micromark("__foo _bar_ baz__"), + to_html("__foo _bar_ baz__"), "

foo bar baz

", "should support nesting emphasis and strong (1)" ); assert_eq!( - micromark("__foo __bar__ baz__"), + to_html("__foo __bar__ baz__"), "

foo bar baz

", "should support nesting emphasis and strong (2)" ); assert_eq!( - micromark("____foo__ bar__"), + to_html("____foo__ bar__"), "

foo bar

", "should support nesting emphasis and strong (3)" ); assert_eq!( - micromark("**foo **bar****"), + to_html("**foo **bar****"), "

foo bar

", "should support nesting emphasis and strong (4)" ); assert_eq!( - micromark("**foo *bar* baz**"), + to_html("**foo *bar* baz**"), "

foo bar baz

", "should support nesting emphasis and strong (5)" ); assert_eq!( - micromark("**foo*bar*baz**"), + to_html("**foo*bar*baz**"), "

foobarbaz

", "should support nesting emphasis and strong (6)" ); assert_eq!( - micromark("***foo* bar**"), + to_html("***foo* bar**"), "

foo bar

", "should support nesting emphasis and strong (7)" ); assert_eq!( - micromark("**foo *bar***"), + to_html("**foo *bar***"), "

foo bar

", "should support nesting emphasis and strong (8)" ); assert_eq!( - micromark("**foo *bar **baz**\nbim* bop**"), + to_html("**foo *bar **baz**\nbim* bop**"), "

foo bar baz\nbim bop

", "should support indefinite nesting of emphasis (1)" ); assert_eq!( - micromark("**foo [*bar*](/url)**"), + to_html("**foo [*bar*](/url)**"), "

foo bar

", "should support indefinite nesting of emphasis (2)" ); assert_eq!( - micromark("__ is not an empty emphasis"), + to_html("__ is not an empty emphasis"), "

__ is not an empty emphasis

", "should not support empty emphasis" ); assert_eq!( - micromark("____ is not an empty emphasis"), + to_html("____ is not an empty emphasis"), "

____ is not an empty emphasis

", "should not support empty strong emphasis" ); // Rule 11. assert_eq!( - micromark("foo ***"), + to_html("foo ***"), "

foo ***

", "should not support emphasis around the same marker" ); assert_eq!( - micromark("foo *\\**"), + to_html("foo *\\**"), "

foo *

", "should support emphasis around an escaped marker" ); assert_eq!( - micromark("foo *_*"), + to_html("foo *_*"), "

foo _

", "should support emphasis around the other marker" ); assert_eq!( - micromark("foo *****"), + to_html("foo *****"), "

foo *****

", "should not support strong emphasis around the same marker" ); assert_eq!( - micromark("foo **\\***"), + to_html("foo **\\***"), "

foo *

", "should support strong emphasis around an escaped marker" ); assert_eq!( - micromark("foo **_**"), + to_html("foo **_**"), "

foo _

", "should support strong emphasis around the other marker" ); assert_eq!( - micromark("**foo*"), + to_html("**foo*"), "

*foo

", "should support a superfluous marker at the start of emphasis" ); assert_eq!( - micromark("*foo**"), + to_html("*foo**"), "

foo*

", "should support a superfluous marker at the end of emphasis" ); assert_eq!( - micromark("***foo**"), + to_html("***foo**"), "

*foo

", "should support a superfluous marker at the start of strong" ); assert_eq!( - micromark("****foo*"), + to_html("****foo*"), "

***foo

", "should support multiple superfluous markers at the start of strong" ); assert_eq!( - micromark("**foo***"), + to_html("**foo***"), "

foo*

", "should support a superfluous marker at the end of strong" ); assert_eq!( - micromark("*foo****"), + to_html("*foo****"), "

foo***

", "should support multiple superfluous markers at the end of strong" ); // Rule 12. assert_eq!( - micromark("foo ___"), + to_html("foo ___"), "

foo ___

", "should not support emphasis around the same marker" ); assert_eq!( - micromark("foo _\\__"), + to_html("foo _\\__"), "

foo _

", "should support emphasis around an escaped marker" ); assert_eq!( - micromark("foo _X_"), + to_html("foo _X_"), "

foo X

", "should support emphasis around the other marker" ); assert_eq!( - micromark("foo _____"), + to_html("foo _____"), "

foo _____

", "should not support strong emphasis around the same marker" ); assert_eq!( - micromark("foo __\\___"), + to_html("foo __\\___"), "

foo _

", "should support strong emphasis around an escaped marker" ); assert_eq!( - micromark("foo __X__"), + to_html("foo __X__"), "

foo X

", "should support strong emphasis around the other marker" ); assert_eq!( - micromark("__foo_"), + to_html("__foo_"), "

_foo

", "should support a superfluous marker at the start of emphasis" ); assert_eq!( - micromark("_foo__"), + to_html("_foo__"), "

foo_

", "should support a superfluous marker at the end of emphasis" ); assert_eq!( - micromark("___foo__"), + to_html("___foo__"), "

_foo

", "should support a superfluous marker at the start of strong" ); assert_eq!( - micromark("____foo_"), + to_html("____foo_"), "

___foo

", "should support multiple superfluous markers at the start of strong" ); assert_eq!( - micromark("__foo___"), + to_html("__foo___"), "

foo_

", "should support a superfluous marker at the end of strong" ); assert_eq!( - micromark("_foo____"), + to_html("_foo____"), "

foo___

", "should support multiple superfluous markers at the end of strong" ); // Rule 13. assert_eq!( - micromark("**foo**"), + to_html("**foo**"), "

foo

", "should support strong w/ `*`" ); assert_eq!( - micromark("*_foo_*"), + to_html("*_foo_*"), "

foo

", "should support emphasis directly in emphasis w/ `_` in `*`" ); assert_eq!( - micromark("__foo__"), + to_html("__foo__"), "

foo

", "should support strong w/ `_`" ); assert_eq!( - micromark("_*foo*_"), + to_html("_*foo*_"), "

foo

", "should support emphasis directly in emphasis w/ `*` in `_`" ); assert_eq!( - micromark("****foo****"), + to_html("****foo****"), "

foo

", "should support strong emphasis directly in strong emphasis w/ `*`" ); assert_eq!( - micromark("____foo____"), + to_html("____foo____"), "

foo

", "should support strong emphasis directly in strong emphasis w/ `_`" ); assert_eq!( - micromark("******foo******"), + to_html("******foo******"), "

foo

", "should support indefinite strong emphasis" ); // Rule 14. assert_eq!( - micromark("***foo***"), + to_html("***foo***"), "

foo

", "should support strong directly in emphasis w/ `*`" ); assert_eq!( - micromark("___foo___"), + to_html("___foo___"), "

foo

", "should support strong directly in emphasis w/ `_`" ); // Rule 15. assert_eq!( - micromark("*foo _bar* baz_"), + to_html("*foo _bar* baz_"), "

foo _bar baz_

", "should not support mismatched emphasis" ); assert_eq!( - micromark("*foo __bar *baz bim__ bam*"), + to_html("*foo __bar *baz bim__ bam*"), "

foo bar *baz bim bam

", "should not support mismatched strong emphasis" ); // Rule 16. assert_eq!( - micromark("**foo **bar baz**"), + to_html("**foo **bar baz**"), "

**foo bar baz

", "should not shortest strong possible" ); assert_eq!( - micromark("*foo *bar baz*"), + to_html("*foo *bar baz*"), "

*foo bar baz

", "should not shortest emphasis possible" ); // Rule 17. assert_eq!( - micromark("*[bar*](/url)"), + to_html("*[bar*](/url)"), "

*bar*

", "should not mismatch inside links (1)" ); assert_eq!( - micromark("_[bar_](/url)"), + to_html("_[bar_](/url)"), "

_bar_

", "should not mismatch inside links (1)" ); assert_eq!( - micromark_with_options("*", &danger)?, + to_html_with_options("*", &danger)?, "

*

", "should not end inside HTML" ); assert_eq!( - micromark_with_options("*", &danger)?, + to_html_with_options("*", &danger)?, "

*

", "should not end emphasis inside HTML" ); assert_eq!( - micromark_with_options("**", &danger)?, + to_html_with_options("**", &danger)?, "

**

", "should not end strong inside HTML (1)" ); assert_eq!( - micromark_with_options("__", &danger)?, + to_html_with_options("__", &danger)?, "

__

", "should not end strong inside HTML (2)" ); assert_eq!( - micromark("*a `*`*"), + to_html("*a `*`*"), "

a *

", "should not end emphasis inside code (1)" ); assert_eq!( - micromark("_a `_`_"), + to_html("_a `_`_"), "

a _

", "should not end emphasis inside code (2)" ); assert_eq!( - micromark("**a"), + to_html("**a"), "

**ahttp://foo.bar/?q=**

", "should not end strong emphasis inside autolinks (1)" ); assert_eq!( - micromark("__a"), + to_html("__a"), "

__ahttp://foo.bar/?q=__

", "should not end strong emphasis inside autolinks (2)" ); assert_eq!( - micromark_with_options( + to_html_with_options( "*a*", &Options { parse: ParseOptions { @@ -839,7 +839,7 @@ fn attention() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("a *alpha* b **bravo** c.", &ParseOptions::default())?, + to_mdast("a *alpha* b **bravo** c.", &ParseOptions::default())?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { children: vec![ -- cgit