diff options
Diffstat (limited to '')
-rw-r--r-- | tests/attention.rs | 272 | ||||
-rw-r--r-- | tests/autolink.rs | 88 |
2 files changed, 180 insertions, 180 deletions
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*"), "<p><em>foo bar</em></p>", "should support emphasis w/ `*`" ); assert_eq!( - micromark("a * foo bar*"), + to_html("a * foo bar*"), "<p>a * foo bar*</p>", "should not support emphasis if the opening is not left flanking (1)" ); assert_eq!( - micromark("a*\"foo\"*"), + to_html("a*\"foo\"*"), "<p>a*"foo"*</p>", "should not support emphasis if the opening is not left flanking (2b)" ); assert_eq!( - micromark("* a *"), + to_html("* a *"), "<p>* a *</p>", "should not support emphasis unicode whitespace either" ); assert_eq!( - micromark("foo*bar*"), + to_html("foo*bar*"), "<p>foo<em>bar</em></p>", "should support intraword emphasis w/ `*` (1)" ); assert_eq!( - micromark("5*6*78"), + to_html("5*6*78"), "<p>5<em>6</em>78</p>", "should support intraword emphasis w/ `*` (2)" ); // Rule 2. assert_eq!( - micromark("_foo bar_"), + to_html("_foo bar_"), "<p><em>foo bar</em></p>", "should support emphasis w/ `_`" ); assert_eq!( - micromark("_ foo bar_"), + to_html("_ foo bar_"), "<p>_ foo bar_</p>", "should not support emphasis if the opening is followed by whitespace" ); assert_eq!( - micromark("a_\"foo\"_"), + to_html("a_\"foo\"_"), "<p>a_"foo"_</p>", "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_"), "<p>foo_bar_</p>", "should not support intraword emphasis (1)" ); assert_eq!( - micromark("5_6_78"), + to_html("5_6_78"), "<p>5_6_78</p>", "should not support intraword emphasis (2)" ); assert_eq!( - micromark("пристаням_стремятся_"), + to_html("пристаням_стремятся_"), "<p>пристаням_стремятся_</p>", "should not support intraword emphasis (3)" ); assert_eq!( - micromark("aa_\"bb\"_cc"), + to_html("aa_\"bb\"_cc"), "<p>aa_"bb"_cc</p>", "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)_"), "<p>foo-<em>(bar)</em></p>", "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*"), "<p>_foo*</p>", "should not support emphasis if opening and closing markers don’t match" ); assert_eq!( - micromark("*foo bar *"), + to_html("*foo bar *"), "<p>*foo bar *</p>", "should not support emphasis w/ `*` if the closing markers are preceded by whitespace" ); assert_eq!( - micromark("*foo bar\n*"), + to_html("*foo bar\n*"), "<p>*foo bar\n*</p>", "should not support emphasis w/ `*` if the closing markers are preceded by a line break (also whitespace)" ); assert_eq!( - micromark("*(*foo)"), + to_html("*(*foo)"), "<p>*(*foo)</p>", "should not support emphasis w/ `*` if the closing markers are not right flanking" ); assert_eq!( - micromark("*(*foo*)*"), + to_html("*(*foo*)*"), "<p><em>(<em>foo</em>)</em></p>", "should support nested emphasis" ); // Rule 4. assert_eq!( - micromark("_foo bar _"), + to_html("_foo bar _"), "<p>_foo bar _</p>", "should not support emphasis if the closing `_` is preceded by whitespace" ); assert_eq!( - micromark("_(_foo)"), + to_html("_(_foo)"), "<p>_(_foo)</p>", "should not support emphasis w/ `_` if the closing markers are not right flanking" ); assert_eq!( - micromark("_(_foo_)_"), + to_html("_(_foo_)_"), "<p><em>(<em>foo</em>)</em></p>", "should support nested emphasis w/ `_`" ); assert_eq!( - micromark("_foo_bar"), + to_html("_foo_bar"), "<p>_foo_bar</p>", "should not support intraword emphasis w/ `_` (1)" ); assert_eq!( - micromark("_пристаням_стремятся"), + to_html("_пристаням_стремятся"), "<p>_пристаням_стремятся</p>", "should not support intraword emphasis w/ `_` (2)" ); assert_eq!( - micromark("_foo_bar_baz_"), + to_html("_foo_bar_baz_"), "<p><em>foo_bar_baz</em></p>", "should not support intraword emphasis w/ `_` (3)" ); assert_eq!( - micromark("_(bar)_."), + to_html("_(bar)_."), "<p><em>(bar)</em>.</p>", "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**"), "<p><strong>foo bar</strong></p>", "should support strong emphasis" ); assert_eq!( - micromark("** foo bar**"), + to_html("** foo bar**"), "<p>** foo bar**</p>", "should not support strong emphasis if the opening is followed by whitespace" ); assert_eq!( - micromark("a**\"foo\"**"), + to_html("a**\"foo\"**"), "<p>a**"foo"**</p>", "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**"), "<p>foo<strong>bar</strong></p>", "should support strong intraword emphasis" ); // Rule 6. assert_eq!( - micromark("__foo bar__"), + to_html("__foo bar__"), "<p><strong>foo bar</strong></p>", "should support strong emphasis w/ `_`" ); assert_eq!( - micromark("__ foo bar__"), + to_html("__ foo bar__"), "<p>__ foo bar__</p>", "should not support strong emphasis if the opening is followed by whitespace" ); assert_eq!( - micromark("__\nfoo bar__"), + to_html("__\nfoo bar__"), "<p>__\nfoo bar__</p>", "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\"__"), "<p>a__"foo"__</p>", "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__"), "<p>foo__bar__</p>", "should not support strong intraword emphasis w/ `_` (1)" ); assert_eq!( - micromark("5__6__78"), + to_html("5__6__78"), "<p>5__6__78</p>", "should not support strong intraword emphasis w/ `_` (2)" ); assert_eq!( - micromark("пристаням__стремятся__"), + to_html("пристаням__стремятся__"), "<p>пристаням__стремятся__</p>", "should not support strong intraword emphasis w/ `_` (3)" ); assert_eq!( - micromark("__foo, __bar__, baz__"), + to_html("__foo, __bar__, baz__"), "<p><strong>foo, <strong>bar</strong>, baz</strong></p>", "should support nested strong emphasis" ); assert_eq!( - micromark("foo-__(bar)__"), + to_html("foo-__(bar)__"), "<p>foo-<strong>(bar)</strong></p>", "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 **"), "<p>**foo bar **</p>", "should not support strong emphasis w/ `*` if the closing is preceded by whitespace" ); assert_eq!( - micromark("**(**foo)"), + to_html("**(**foo)"), "<p>**(**foo)</p>", "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**)*"), "<p><em>(<strong>foo</strong>)</em></p>", "should support strong emphasis in emphasis" ); assert_eq!( - micromark( + to_html( "**Gomphocarpus (*Gomphocarpus physocarpus*, syn.\n*Asclepias physocarpa*)**" ), "<p><strong>Gomphocarpus (<em>Gomphocarpus physocarpus</em>, syn.\n<em>Asclepias physocarpa</em>)</strong></p>", @@ -286,542 +286,542 @@ fn attention() -> Result<(), String> { ); assert_eq!( - micromark("**foo \"*bar*\" foo**"), + to_html("**foo \"*bar*\" foo**"), "<p><strong>foo "<em>bar</em>" foo</strong></p>", "should support emphasis in strong emphasis (2)" ); assert_eq!( - micromark("**foo**bar"), + to_html("**foo**bar"), "<p><strong>foo</strong>bar</p>", "should support strong intraword emphasis" ); // Rule 8. assert_eq!( - micromark("__foo bar __"), + to_html("__foo bar __"), "<p>__foo bar __</p>", "should not support strong emphasis w/ `_` if the closing is preceded by whitespace" ); assert_eq!( - micromark("__(__foo)"), + to_html("__(__foo)"), "<p>__(__foo)</p>", "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__)_"), "<p><em>(<strong>foo</strong>)</em></p>", "should support strong emphasis w/ `_` in emphasis" ); assert_eq!( - micromark("__foo__bar"), + to_html("__foo__bar"), "<p>__foo__bar</p>", "should not support strong intraword emphasis w/ `_` (1)" ); assert_eq!( - micromark("__пристаням__стремятся"), + to_html("__пристаням__стремятся"), "<p>__пристаням__стремятся</p>", "should not support strong intraword emphasis w/ `_` (2)" ); assert_eq!( - micromark("__foo__bar__baz__"), + to_html("__foo__bar__baz__"), "<p><strong>foo__bar__baz</strong></p>", "should not support strong intraword emphasis w/ `_` (3)" ); assert_eq!( - micromark("__(bar)__."), + to_html("__(bar)__."), "<p><strong>(bar)</strong>.</p>", "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)*"), "<p><em>foo <a href=\"/url\">bar</a></em></p>", "should support content in emphasis" ); assert_eq!( - micromark("*foo\nbar*"), + to_html("*foo\nbar*"), "<p><em>foo\nbar</em></p>", "should support line endings in emphasis" ); assert_eq!( - micromark("_foo __bar__ baz_"), + to_html("_foo __bar__ baz_"), "<p><em>foo <strong>bar</strong> baz</em></p>", "should support nesting emphasis and strong (1)" ); assert_eq!( - micromark("_foo _bar_ baz_"), + to_html("_foo _bar_ baz_"), "<p><em>foo <em>bar</em> baz</em></p>", "should support nesting emphasis and strong (2)" ); assert_eq!( - micromark("__foo_ bar_"), + to_html("__foo_ bar_"), "<p><em><em>foo</em> bar</em></p>", "should support nesting emphasis and strong (3)" ); assert_eq!( - micromark("*foo *bar**"), + to_html("*foo *bar**"), "<p><em>foo <em>bar</em></em></p>", "should support nesting emphasis and strong (4)" ); assert_eq!( - micromark("*foo **bar** baz*"), + to_html("*foo **bar** baz*"), "<p><em>foo <strong>bar</strong> baz</em></p>", "should support nesting emphasis and strong (5)" ); assert_eq!( - micromark("*foo**bar**baz*"), + to_html("*foo**bar**baz*"), "<p><em>foo<strong>bar</strong>baz</em></p>", "should support nesting emphasis and strong (6)" ); assert_eq!( - micromark("*foo**bar*"), + to_html("*foo**bar*"), "<p><em>foo**bar</em></p>", "should not support adjacent emphasis in certain cases" ); assert_eq!( - micromark("***foo** bar*"), + to_html("***foo** bar*"), "<p><em><strong>foo</strong> bar</em></p>", "complex (1)" ); assert_eq!( - micromark("*foo **bar***"), + to_html("*foo **bar***"), "<p><em>foo <strong>bar</strong></em></p>", "complex (2)" ); assert_eq!( - micromark("*foo**bar***"), + to_html("*foo**bar***"), "<p><em>foo<strong>bar</strong></em></p>", "complex (3)" ); assert_eq!( - micromark("foo***bar***baz"), + to_html("foo***bar***baz"), "<p>foo<em><strong>bar</strong></em>baz</p>", "complex (a)" ); assert_eq!( - micromark("foo******bar*********baz"), + to_html("foo******bar*********baz"), "<p>foo<strong><strong><strong>bar</strong></strong></strong>***baz</p>", "complex (b)" ); assert_eq!( - micromark("*foo **bar *baz* bim** bop*"), + to_html("*foo **bar *baz* bim** bop*"), "<p><em>foo <strong>bar <em>baz</em> bim</strong> bop</em></p>", "should support indefinite nesting of emphasis (1)" ); assert_eq!( - micromark("*foo [*bar*](/url)*"), + to_html("*foo [*bar*](/url)*"), "<p><em>foo <a href=\"/url\"><em>bar</em></a></em></p>", "should support indefinite nesting of emphasis (2)" ); assert_eq!( - micromark("** is not an empty emphasis"), + to_html("** is not an empty emphasis"), "<p>** is not an empty emphasis</p>", "should not support empty emphasis" ); assert_eq!( - micromark("**** is not an empty emphasis"), + to_html("**** is not an empty emphasis"), "<p>**** is not an empty emphasis</p>", "should not support empty strong emphasis" ); // Rule 10. assert_eq!( - micromark("**foo [bar](/url)**"), + to_html("**foo [bar](/url)**"), "<p><strong>foo <a href=\"/url\">bar</a></strong></p>", "should support content in strong emphasis" ); assert_eq!( - micromark("**foo\nbar**"), + to_html("**foo\nbar**"), "<p><strong>foo\nbar</strong></p>", "should support line endings in emphasis" ); assert_eq!( - micromark("__foo _bar_ baz__"), + to_html("__foo _bar_ baz__"), "<p><strong>foo <em>bar</em> baz</strong></p>", "should support nesting emphasis and strong (1)" ); assert_eq!( - micromark("__foo __bar__ baz__"), + to_html("__foo __bar__ baz__"), "<p><strong>foo <strong>bar</strong> baz</strong></p>", "should support nesting emphasis and strong (2)" ); assert_eq!( - micromark("____foo__ bar__"), + to_html("____foo__ bar__"), "<p><strong><strong>foo</strong> bar</strong></p>", "should support nesting emphasis and strong (3)" ); assert_eq!( - micromark("**foo **bar****"), + to_html("**foo **bar****"), "<p><strong>foo <strong>bar</strong></strong></p>", "should support nesting emphasis and strong (4)" ); assert_eq!( - micromark("**foo *bar* baz**"), + to_html("**foo *bar* baz**"), "<p><strong>foo <em>bar</em> baz</strong></p>", "should support nesting emphasis and strong (5)" ); assert_eq!( - micromark("**foo*bar*baz**"), + to_html("**foo*bar*baz**"), "<p><strong>foo<em>bar</em>baz</strong></p>", "should support nesting emphasis and strong (6)" ); assert_eq!( - micromark("***foo* bar**"), + to_html("***foo* bar**"), "<p><strong><em>foo</em> bar</strong></p>", "should support nesting emphasis and strong (7)" ); assert_eq!( - micromark("**foo *bar***"), + to_html("**foo *bar***"), "<p><strong>foo <em>bar</em></strong></p>", "should support nesting emphasis and strong (8)" ); assert_eq!( - micromark("**foo *bar **baz**\nbim* bop**"), + to_html("**foo *bar **baz**\nbim* bop**"), "<p><strong>foo <em>bar <strong>baz</strong>\nbim</em> bop</strong></p>", "should support indefinite nesting of emphasis (1)" ); assert_eq!( - micromark("**foo [*bar*](/url)**"), + to_html("**foo [*bar*](/url)**"), "<p><strong>foo <a href=\"/url\"><em>bar</em></a></strong></p>", "should support indefinite nesting of emphasis (2)" ); assert_eq!( - micromark("__ is not an empty emphasis"), + to_html("__ is not an empty emphasis"), "<p>__ is not an empty emphasis</p>", "should not support empty emphasis" ); assert_eq!( - micromark("____ is not an empty emphasis"), + to_html("____ is not an empty emphasis"), "<p>____ is not an empty emphasis</p>", "should not support empty strong emphasis" ); // Rule 11. assert_eq!( - micromark("foo ***"), + to_html("foo ***"), "<p>foo ***</p>", "should not support emphasis around the same marker" ); assert_eq!( - micromark("foo *\\**"), + to_html("foo *\\**"), "<p>foo <em>*</em></p>", "should support emphasis around an escaped marker" ); assert_eq!( - micromark("foo *_*"), + to_html("foo *_*"), "<p>foo <em>_</em></p>", "should support emphasis around the other marker" ); assert_eq!( - micromark("foo *****"), + to_html("foo *****"), "<p>foo *****</p>", "should not support strong emphasis around the same marker" ); assert_eq!( - micromark("foo **\\***"), + to_html("foo **\\***"), "<p>foo <strong>*</strong></p>", "should support strong emphasis around an escaped marker" ); assert_eq!( - micromark("foo **_**"), + to_html("foo **_**"), "<p>foo <strong>_</strong></p>", "should support strong emphasis around the other marker" ); assert_eq!( - micromark("**foo*"), + to_html("**foo*"), "<p>*<em>foo</em></p>", "should support a superfluous marker at the start of emphasis" ); assert_eq!( - micromark("*foo**"), + to_html("*foo**"), "<p><em>foo</em>*</p>", "should support a superfluous marker at the end of emphasis" ); assert_eq!( - micromark("***foo**"), + to_html("***foo**"), "<p>*<strong>foo</strong></p>", "should support a superfluous marker at the start of strong" ); assert_eq!( - micromark("****foo*"), + to_html("****foo*"), "<p>***<em>foo</em></p>", "should support multiple superfluous markers at the start of strong" ); assert_eq!( - micromark("**foo***"), + to_html("**foo***"), "<p><strong>foo</strong>*</p>", "should support a superfluous marker at the end of strong" ); assert_eq!( - micromark("*foo****"), + to_html("*foo****"), "<p><em>foo</em>***</p>", "should support multiple superfluous markers at the end of strong" ); // Rule 12. assert_eq!( - micromark("foo ___"), + to_html("foo ___"), "<p>foo ___</p>", "should not support emphasis around the same marker" ); assert_eq!( - micromark("foo _\\__"), + to_html("foo _\\__"), "<p>foo <em>_</em></p>", "should support emphasis around an escaped marker" ); assert_eq!( - micromark("foo _X_"), + to_html("foo _X_"), "<p>foo <em>X</em></p>", "should support emphasis around the other marker" ); assert_eq!( - micromark("foo _____"), + to_html("foo _____"), "<p>foo _____</p>", "should not support strong emphasis around the same marker" ); assert_eq!( - micromark("foo __\\___"), + to_html("foo __\\___"), "<p>foo <strong>_</strong></p>", "should support strong emphasis around an escaped marker" ); assert_eq!( - micromark("foo __X__"), + to_html("foo __X__"), "<p>foo <strong>X</strong></p>", "should support strong emphasis around the other marker" ); assert_eq!( - micromark("__foo_"), + to_html("__foo_"), "<p>_<em>foo</em></p>", "should support a superfluous marker at the start of emphasis" ); assert_eq!( - micromark("_foo__"), + to_html("_foo__"), "<p><em>foo</em>_</p>", "should support a superfluous marker at the end of emphasis" ); assert_eq!( - micromark("___foo__"), + to_html("___foo__"), "<p>_<strong>foo</strong></p>", "should support a superfluous marker at the start of strong" ); assert_eq!( - micromark("____foo_"), + to_html("____foo_"), "<p>___<em>foo</em></p>", "should support multiple superfluous markers at the start of strong" ); assert_eq!( - micromark("__foo___"), + to_html("__foo___"), "<p><strong>foo</strong>_</p>", "should support a superfluous marker at the end of strong" ); assert_eq!( - micromark("_foo____"), + to_html("_foo____"), "<p><em>foo</em>___</p>", "should support multiple superfluous markers at the end of strong" ); // Rule 13. assert_eq!( - micromark("**foo**"), + to_html("**foo**"), "<p><strong>foo</strong></p>", "should support strong w/ `*`" ); assert_eq!( - micromark("*_foo_*"), + to_html("*_foo_*"), "<p><em><em>foo</em></em></p>", "should support emphasis directly in emphasis w/ `_` in `*`" ); assert_eq!( - micromark("__foo__"), + to_html("__foo__"), "<p><strong>foo</strong></p>", "should support strong w/ `_`" ); assert_eq!( - micromark("_*foo*_"), + to_html("_*foo*_"), "<p><em><em>foo</em></em></p>", "should support emphasis directly in emphasis w/ `*` in `_`" ); assert_eq!( - micromark("****foo****"), + to_html("****foo****"), "<p><strong><strong>foo</strong></strong></p>", "should support strong emphasis directly in strong emphasis w/ `*`" ); assert_eq!( - micromark("____foo____"), + to_html("____foo____"), "<p><strong><strong>foo</strong></strong></p>", "should support strong emphasis directly in strong emphasis w/ `_`" ); assert_eq!( - micromark("******foo******"), + to_html("******foo******"), "<p><strong><strong><strong>foo</strong></strong></strong></p>", "should support indefinite strong emphasis" ); // Rule 14. assert_eq!( - micromark("***foo***"), + to_html("***foo***"), "<p><em><strong>foo</strong></em></p>", "should support strong directly in emphasis w/ `*`" ); assert_eq!( - micromark("___foo___"), + to_html("___foo___"), "<p><em><strong>foo</strong></em></p>", "should support strong directly in emphasis w/ `_`" ); // Rule 15. assert_eq!( - micromark("*foo _bar* baz_"), + to_html("*foo _bar* baz_"), "<p><em>foo _bar</em> baz_</p>", "should not support mismatched emphasis" ); assert_eq!( - micromark("*foo __bar *baz bim__ bam*"), + to_html("*foo __bar *baz bim__ bam*"), "<p><em>foo <strong>bar *baz bim</strong> bam</em></p>", "should not support mismatched strong emphasis" ); // Rule 16. assert_eq!( - micromark("**foo **bar baz**"), + to_html("**foo **bar baz**"), "<p>**foo <strong>bar baz</strong></p>", "should not shortest strong possible" ); assert_eq!( - micromark("*foo *bar baz*"), + to_html("*foo *bar baz*"), "<p>*foo <em>bar baz</em></p>", "should not shortest emphasis possible" ); // Rule 17. assert_eq!( - micromark("*[bar*](/url)"), + to_html("*[bar*](/url)"), "<p>*<a href=\"/url\">bar*</a></p>", "should not mismatch inside links (1)" ); assert_eq!( - micromark("_[bar_](/url)"), + to_html("_[bar_](/url)"), "<p>_<a href=\"/url\">bar_</a></p>", "should not mismatch inside links (1)" ); assert_eq!( - micromark_with_options("*<img src=\"foo\" title=\"*\"/>", &danger)?, + to_html_with_options("*<img src=\"foo\" title=\"*\"/>", &danger)?, "<p>*<img src=\"foo\" title=\"*\"/></p>", "should not end inside HTML" ); assert_eq!( - micromark_with_options("*<img src=\"foo\" title=\"*\"/>", &danger)?, + to_html_with_options("*<img src=\"foo\" title=\"*\"/>", &danger)?, "<p>*<img src=\"foo\" title=\"*\"/></p>", "should not end emphasis inside HTML" ); assert_eq!( - micromark_with_options("**<a href=\"**\">", &danger)?, + to_html_with_options("**<a href=\"**\">", &danger)?, "<p>**<a href=\"**\"></p>", "should not end strong inside HTML (1)" ); assert_eq!( - micromark_with_options("__<a href=\"__\">", &danger)?, + to_html_with_options("__<a href=\"__\">", &danger)?, "<p>__<a href=\"__\"></p>", "should not end strong inside HTML (2)" ); assert_eq!( - micromark("*a `*`*"), + to_html("*a `*`*"), "<p><em>a <code>*</code></em></p>", "should not end emphasis inside code (1)" ); assert_eq!( - micromark("_a `_`_"), + to_html("_a `_`_"), "<p><em>a <code>_</code></em></p>", "should not end emphasis inside code (2)" ); assert_eq!( - micromark("**a<http://foo.bar/?q=**>"), + to_html("**a<http://foo.bar/?q=**>"), "<p>**a<a href=\"http://foo.bar/?q=**\">http://foo.bar/?q=**</a></p>", "should not end strong emphasis inside autolinks (1)" ); assert_eq!( - micromark("__a<http://foo.bar/?q=__>"), + to_html("__a<http://foo.bar/?q=__>"), "<p>__a<a href=\"http://foo.bar/?q=__\">http://foo.bar/?q=__</a></p>", "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![ diff --git a/tests/autolink.rs b/tests/autolink.rs index d2b0956..1b20e08 100644 --- a/tests/autolink.rs +++ b/tests/autolink.rs @@ -1,7 +1,7 @@ -extern crate micromark; -use micromark::{ +extern crate markdown; +use markdown::{ mdast::{Link, Node, Paragraph, Root, Text}, - micromark, micromark_to_mdast, micromark_with_options, + to_html, to_html_with_options, to_mdast, unist::Position, CompileOptions, Constructs, Options, ParseOptions, }; @@ -19,241 +19,241 @@ fn autolink() -> Result<(), String> { }; assert_eq!( - micromark("<http://foo.bar.baz>"), + to_html("<http://foo.bar.baz>"), "<p><a href=\"http://foo.bar.baz\">http://foo.bar.baz</a></p>", "should support protocol autolinks (1)" ); assert_eq!( - micromark("<http://foo.bar.baz/test?q=hello&id=22&boolean>"), + to_html("<http://foo.bar.baz/test?q=hello&id=22&boolean>"), "<p><a href=\"http://foo.bar.baz/test?q=hello&id=22&boolean\">http://foo.bar.baz/test?q=hello&id=22&boolean</a></p>", "should support protocol autolinks (2)" ); assert_eq!( - micromark("<irc://foo.bar:2233/baz>"), + to_html("<irc://foo.bar:2233/baz>"), "<p><a href=\"irc://foo.bar:2233/baz\">irc://foo.bar:2233/baz</a></p>", "should support protocol autolinks w/ non-HTTP schemes" ); assert_eq!( - micromark("<MAILTO:FOO@BAR.BAZ>"), + to_html("<MAILTO:FOO@BAR.BAZ>"), "<p><a href=\"MAILTO:FOO@BAR.BAZ\">MAILTO:FOO@BAR.BAZ</a></p>", "should support protocol autolinks in uppercase" ); assert_eq!( - micromark("<a+b+c:d>"), + to_html("<a+b+c:d>"), "<p><a href=\"\">a+b+c:d</a></p>", "should support protocol autolinks w/ incorrect URIs (1, default)" ); assert_eq!( - micromark_with_options("<a+b+c:d>", &danger)?, + to_html_with_options("<a+b+c:d>", &danger)?, "<p><a href=\"a+b+c:d\">a+b+c:d</a></p>", "should support protocol autolinks w/ incorrect URIs (1, danger)" ); assert_eq!( - micromark("<made-up-scheme://foo,bar>"), + to_html("<made-up-scheme://foo,bar>"), "<p><a href=\"\">made-up-scheme://foo,bar</a></p>", "should support protocol autolinks w/ incorrect URIs (2, default)" ); assert_eq!( - micromark_with_options("<made-up-scheme://foo,bar>", &danger)?, + to_html_with_options("<made-up-scheme://foo,bar>", &danger)?, "<p><a href=\"made-up-scheme://foo,bar\">made-up-scheme://foo,bar</a></p>", "should support protocol autolinks w/ incorrect URIs (2, danger)" ); assert_eq!( - micromark("<http://../>"), + to_html("<http://../>"), "<p><a href=\"http://../\">http://../</a></p>", "should support protocol autolinks w/ incorrect URIs (3)" ); assert_eq!( - micromark_with_options("<localhost:5001/foo>", &danger)?, + to_html_with_options("<localhost:5001/foo>", &danger)?, "<p><a href=\"localhost:5001/foo\">localhost:5001/foo</a></p>", "should support protocol autolinks w/ incorrect URIs (4)" ); assert_eq!( - micromark("<http://foo.bar/baz bim>"), + to_html("<http://foo.bar/baz bim>"), "<p><http://foo.bar/baz bim></p>", "should not support protocol autolinks w/ spaces" ); assert_eq!( - micromark("<http://example.com/\\[\\>"), + to_html("<http://example.com/\\[\\>"), "<p><a href=\"http://example.com/%5C%5B%5C\">http://example.com/\\[\\</a></p>", "should not support character escapes in protocol autolinks" ); assert_eq!( - micromark("<foo@bar.example.com>"), + to_html("<foo@bar.example.com>"), "<p><a href=\"mailto:foo@bar.example.com\">foo@bar.example.com</a></p>", "should support email autolinks (1)" ); assert_eq!( - micromark("<foo+special@Bar.baz-bar0.com>"), + to_html("<foo+special@Bar.baz-bar0.com>"), "<p><a href=\"mailto:foo+special@Bar.baz-bar0.com\">foo+special@Bar.baz-bar0.com</a></p>", "should support email autolinks (2)" ); assert_eq!( - micromark("<a@b.c>"), + to_html("<a@b.c>"), "<p><a href=\"mailto:a@b.c\">a@b.c</a></p>", "should support email autolinks (3)" ); assert_eq!( - micromark("<foo\\+@bar.example.com>"), + to_html("<foo\\+@bar.example.com>"), "<p><foo+@bar.example.com></p>", "should not support character escapes in email autolinks" ); assert_eq!( - micromark("<>"), + to_html("<>"), "<p><></p>", "should not support empty autolinks" ); assert_eq!( - micromark("< http://foo.bar >"), + to_html("< http://foo.bar >"), "<p>< http://foo.bar ></p>", "should not support autolinks w/ space" ); assert_eq!( - micromark("<m:abc>"), + to_html("<m:abc>"), "<p><m:abc></p>", "should not support autolinks w/ a single character for a scheme" ); assert_eq!( - micromark("<foo.bar.baz>"), + to_html("<foo.bar.baz>"), "<p><foo.bar.baz></p>", "should not support autolinks w/o a colon or at sign" ); assert_eq!( - micromark("http://example.com"), + to_html("http://example.com"), "<p>http://example.com</p>", "should not support protocol autolinks w/o angle brackets" ); assert_eq!( - micromark("foo@bar.example.com"), + to_html("foo@bar.example.com"), "<p>foo@bar.example.com</p>", "should not support email autolinks w/o angle brackets" ); // Extra: assert_eq!( - micromark("<*@example.com>"), + to_html("<*@example.com>"), "<p><a href=\"mailto:*@example.com\">*@example.com</a></p>", "should support autolinks w/ atext (1)" ); assert_eq!( - micromark("<a*@example.com>"), + to_html("<a*@example.com>"), "<p><a href=\"mailto:a*@example.com\">a*@example.com</a></p>", "should support autolinks w/ atext (2)" ); assert_eq!( - micromark("<aa*@example.com>"), + to_html("<aa*@example.com>"), "<p><a href=\"mailto:aa*@example.com\">aa*@example.com</a></p>", "should support autolinks w/ atext (3)" ); assert_eq!( - micromark("<aaa©@example.com>"), + to_html("<aaa©@example.com>"), "<p><aaa©@example.com></p>", "should support non-atext in email autolinks local part (1)" ); assert_eq!( - micromark("<a*a©@example.com>"), + to_html("<a*a©@example.com>"), "<p><a*a©@example.com></p>", "should support non-atext in email autolinks local part (2)" ); assert_eq!( - micromark("<asd@.example.com>"), + to_html("<asd@.example.com>"), "<p><asd@.example.com></p>", "should not support a dot after an at sign in email autolinks" ); assert_eq!( - micromark("<asd@e..xample.com>"), + to_html("<asd@e..xample.com>"), "<p><asd@e..xample.com></p>", "should not support a dot after another dot in email autolinks" ); assert_eq!( - micromark( + to_html( "<asd@012345678901234567890123456789012345678901234567890123456789012>"), "<p><a href=\"mailto:asd@012345678901234567890123456789012345678901234567890123456789012\">asd@012345678901234567890123456789012345678901234567890123456789012</a></p>", "should support 63 character in email autolinks domains" ); assert_eq!( - micromark("<asd@0123456789012345678901234567890123456789012345678901234567890123>"), + to_html("<asd@0123456789012345678901234567890123456789012345678901234567890123>"), "<p><asd@0123456789012345678901234567890123456789012345678901234567890123></p>", "should not support 64 character in email autolinks domains" ); assert_eq!( - micromark( + to_html( "<asd@012345678901234567890123456789012345678901234567890123456789012.a>"), "<p><a href=\"mailto:asd@012345678901234567890123456789012345678901234567890123456789012.a\">asd@012345678901234567890123456789012345678901234567890123456789012.a</a></p>", "should support a TLD after a 63 character domain in email autolinks" ); assert_eq!( - micromark("<asd@0123456789012345678901234567890123456789012345678901234567890123.a>"), + to_html("<asd@0123456789012345678901234567890123456789012345678901234567890123.a>"), "<p><asd@0123456789012345678901234567890123456789012345678901234567890123.a></p>", "should not support a TLD after a 64 character domain in email autolinks" ); assert_eq!( - micromark( + to_html( "<asd@a.012345678901234567890123456789012345678901234567890123456789012>"), "<p><a href=\"mailto:asd@a.012345678901234567890123456789012345678901234567890123456789012\">asd@a.012345678901234567890123456789012345678901234567890123456789012</a></p>", "should support a 63 character TLD in email autolinks" ); assert_eq!( - micromark("<asd@a.0123456789012345678901234567890123456789012345678901234567890123>"), + to_html("<asd@a.0123456789012345678901234567890123456789012345678901234567890123>"), "<p><asd@a.0123456789012345678901234567890123456789012345678901234567890123></p>", "should not support a 64 character TLD in email autolinks" ); assert_eq!( - micromark("<asd@-example.com>"), + to_html("<asd@-example.com>"), "<p><asd@-example.com></p>", "should not support a dash after `@` in email autolinks" ); assert_eq!( - micromark("<asd@e-xample.com>"), + to_html("<asd@e-xample.com>"), "<p><a href=\"mailto:asd@e-xample.com\">asd@e-xample.com</a></p>", "should support a dash after other domain characters in email autolinks" ); assert_eq!( - micromark("<asd@e--xample.com>"), + to_html("<asd@e--xample.com>"), "<p><a href=\"mailto:asd@e--xample.com\">asd@e--xample.com</a></p>", "should support a dash after another dash in email autolinks" ); assert_eq!( - micromark("<asd@example-.com>"), + to_html("<asd@example-.com>"), "<p><asd@example-.com></p>", "should not support a dash before a dot in email autolinks" ); assert_eq!( - micromark_with_options( + to_html_with_options( "<a@b.co>", &Options { parse: ParseOptions { @@ -271,7 +271,7 @@ fn autolink() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast( + to_mdast( "a <https://alpha.com> b <bravo@charlie.com> c.", &ParseOptions::default() )?, |