",
"won't be affected by email addresses that have a number before the @ symbol");
assert.cooked("@EvilTrout yo",
@@ -269,7 +305,7 @@ QUnit.test("Mentions", assert => {
"it handles mentions at the beginning of a string");
assert.cooked("yo\n@EvilTrout",
- "
yo @EvilTrout
",
+ "
yo \n@EvilTrout
",
"it handles mentions at the beginning of a new line");
assert.cooked("`evil` @EvilTrout `trout`",
@@ -277,15 +313,15 @@ QUnit.test("Mentions", assert => {
"deals correctly with multiple blocks");
assert.cooked("```\na @test\n```",
- "
a @test
",
+ "
a @test\n
",
"should not do mentions within a code block.");
assert.cooked("> foo bar baz @eviltrout",
- "
foo bar baz @eviltrout
",
+ "
\n
foo bar baz @eviltrout
\n
",
"handles mentions in simple quotes");
assert.cooked("> foo bar baz @eviltrout ohmagerd\nlook at this",
- "
foo bar baz @eviltrout ohmagerd look at this
",
+ "
\n
foo bar baz @eviltrout ohmagerd \nlook at this
\n
",
"does mentions properly with trailing text within a simple quote");
assert.cooked("`code` is okay before @mention",
@@ -309,7 +345,7 @@ QUnit.test("Mentions", assert => {
"you can have a mention in an inline code block following a real mention.");
assert.cooked("1. this is a list\n\n2. this is an @eviltrout mention\n",
- "
this is a list
this is an @eviltrout mention
",
+ "\n
\n
this is a list
\n
\n
\n
this is an @eviltrout mention
\n
\n",
"it mentions properly in a list.");
assert.cooked("Hello @foo/@bar",
@@ -341,11 +377,11 @@ QUnit.test("Category hashtags", assert => {
"it does not translate category hashtag within links");
assert.cooked("```\n# #category-hashtag\n```",
- "
# #category-hashtag
",
+ "
# #category-hashtag\n
",
"it does not translate category hashtags to links in code blocks");
assert.cooked("># #category-hashtag\n",
- "
",
"it does not mention in an inline code block");
- assert.cooked("test #hashtag1/#hashtag2",
- "
test #hashtag1/#hashtag2
",
- "it does not convert category hashtag not bounded by spaces");
-
assert.cooked("#category-hashtag",
"
#category-hashtag
",
"it works between HTML tags");
@@ -371,14 +403,12 @@ QUnit.test("Heading", assert => {
});
QUnit.test("bold and italics", assert => {
- assert.cooked("a \"**hello**\"", "
a \"hello\"
", "bolds in quotes");
+ assert.cooked("a \"**hello**\"", "
a "hello"
", "bolds in quotes");
assert.cooked("(**hello**)", "
(hello)
", "bolds in parens");
- assert.cooked("**hello**\nworld", "
hello world
", "allows newline after bold");
- assert.cooked("**hello**\n**world**", "
hello world
", "newline between two bolds");
- assert.cooked("**a*_b**", "
a*_b
", "allows for characters within bold");
+ assert.cooked("**hello**\nworld", "
hello \nworld
", "allows newline after bold");
+ assert.cooked("**hello**\n**world**", "
hello \nworld
", "newline between two bolds");
assert.cooked("** hello**", "
** hello**
", "does not bold on a space boundary");
assert.cooked("**hello **", "
**hello **
", "does not bold on a space boundary");
- assert.cooked("你**hello**", "
你**hello**
", "does not bold chinese intra word");
assert.cooked("**你hello**", "
你hello
", "allows bolded chinese");
});
@@ -388,10 +418,11 @@ QUnit.test("Escaping", assert => {
});
QUnit.test("New Lines", assert => {
- // Note: This behavior was discussed and we determined it does not make sense to do this
- // unless you're using traditional line breaks
- assert.cooked("_abc\ndef_", "
_abc def_
", "it does not allow markup to span new lines");
- assert.cooked("_abc\n\ndef_", "
_abc
\n\n
def_
", "it does not allow markup to span new paragraphs");
+ // historically we would not continue inline em or b across lines,
+ // however commonmark gives us no switch to do so and we would be very non compliant.
+ // turning softbreaks into a newline is just a renderer option, not a parser switch.
+ assert.cooked("_abc\ndef_", "
abc \ndef
", "it does allow inlines to span new lines");
+ assert.cooked("_abc\n\ndef_", "
_abc
\n
def_
", "it does not allow inlines to span new paragraphs");
});
QUnit.test("Oneboxing", assert => {
@@ -408,9 +439,9 @@ QUnit.test("Oneboxing", assert => {
assert.ok(!matches("http://test.com bob", /onebox/), "doesn't onebox links that have trailing text");
assert.ok(!matches("[Tom Cruise](http://www.tomcruise.com/)", "onebox"), "Markdown links with labels are not oneboxed");
- assert.ok(matches("[http://www.tomcruise.com/](http://www.tomcruise.com/)",
+ assert.ok(!matches("[http://www.tomcruise.com/](http://www.tomcruise.com/)",
"onebox"),
- "Markdown links where the label is the same as the url are oneboxed");
+ "Markdown links where the label is the same as the url but link is explicit");
assert.cooked("http://en.wikipedia.org/wiki/Homicide:_Life_on_the_Street",
"
",
"it works when nesting standard markdown code blocks within a fenced code block");
assert.cooked("`$&`",
@@ -575,47 +606,42 @@ QUnit.test('basic bbcode', assert => {
assert.cookedPara("[i]emphasis[/i]", "emphasis", "italics text");
assert.cookedPara("[u]underlined[/u]", "underlined", "underlines text");
assert.cookedPara("[s]strikethrough[/s]", "strikethrough", "strikes-through text");
- assert.cookedPara("[img]http://eviltrout.com/eviltrout.png[/img]", "", "links images");
- assert.cookedPara("[email]eviltrout@mailinator.com[/email]", "eviltrout@mailinator.com", "supports [email] without a title");
+ assert.cookedPara("[img]http://eviltrout.com/eviltrout.png[/img]", "", "links images");
+ assert.cookedPara("[email]eviltrout@mailinator.com[/email]", "eviltrout@mailinator.com", "supports [email] without a title");
assert.cookedPara("[b]evil [i]trout[/i][/b]",
"evil trout",
"allows embedding of tags");
- assert.cookedPara("[EMAIL]eviltrout@mailinator.com[/EMAIL]", "eviltrout@mailinator.com", "supports upper case bbcode");
+ assert.cookedPara("[EMAIL]eviltrout@mailinator.com[/EMAIL]", "eviltrout@mailinator.com", "supports upper case bbcode");
assert.cookedPara("[b]strong [b]stronger[/b][/b]", "strong stronger", "accepts nested bbcode tags");
});
QUnit.test('urls', assert => {
assert.cookedPara("[url]not a url[/url]", "not a url", "supports [url] that isn't a url");
- assert.cookedPara("[url]abc.com[/url]", "abc.com", "no error when a url has no protocol and begins with a");
- assert.cookedPara("[url]http://bettercallsaul.com[/url]", "http://bettercallsaul.com", "supports [url] without parameter");
- assert.cookedPara("[url=http://example.com]example[/url]", "example", "supports [url] with given href");
+ assert.cookedPara("[url]abc.com[/url]", "abc.com", "it magically links using linkify");
+ assert.cookedPara("[url]http://bettercallsaul.com[/url]", "http://bettercallsaul.com", "supports [url] without parameter");
+ assert.cookedPara("[url=http://example.com]example[/url]", "example", "supports [url] with given href");
assert.cookedPara("[url=http://www.example.com][img]http://example.com/logo.png[/img][/url]",
- "",
+ "",
"supports [url] with an embedded [img]");
});
QUnit.test('invalid bbcode', assert => {
- const result = new PrettyText({ lookupAvatar: false }).cook("[code]I am not closed\n\nThis text exists.");
- assert.equal(result, "
[code]I am not closed
\n\n
This text exists.
", "does not raise an error with an open bbcode tag.");
+ assert.cooked("[code]I am not closed\n\nThis text exists.",
+ "
[code]I am not closed
\n
This text exists.
",
+ "does not raise an error with an open bbcode tag.");
});
QUnit.test('code', assert => {
- assert.cookedPara("[code]\nx++\n[/code]", "
x++
", "makes code into pre");
- assert.cookedPara("[code]\nx++\ny++\nz++\n[/code]", "
x++\ny++\nz++
", "makes code into pre");
- assert.cookedPara("[code]abc\n#def\n[/code]", '
abc\n#def
', 'it handles headings in a [code] block');
- assert.cookedPara("[code]\n s[/code]",
+ assert.cooked("[code]\nx++\n[/code]", "
x++
", "makes code into pre");
+ assert.cooked("[code]\nx++\ny++\nz++\n[/code]", "
x++\ny++\nz++
", "makes code into pre");
+ assert.cooked("[code]\nabc\n#def\n[/code]", '
abc\n#def
', 'it handles headings in a [code] block');
+ assert.cooked("[code]\n s\n[/code]",
"
s
",
"it doesn't trim leading whitespace");
});
-QUnit.test('lists', assert => {
- assert.cookedPara("[ul][li]option one[/li][/ul]", "
option one
", "creates an ul");
- assert.cookedPara("[ol][li]option one[/li][/ol]", "
option one
", "creates an ol");
- assert.cookedPara("[ul]\n[li]option one[/li]\n[li]option two[/li]\n[/ul]", "
option one
option two
", "suppresses empty lines in lists");
-});
-
QUnit.test('tags with arguments', assert => {
- assert.cookedPara("[url=http://bettercallsaul.com]better call![/url]", "better call!", "supports [url] with a title");
- assert.cookedPara("[email=eviltrout@mailinator.com]evil trout[/email]", "evil trout", "supports [email] with a title");
+ assert.cookedPara("[url=http://bettercallsaul.com]better call![/url]", "better call!", "supports [url] with a title");
+ assert.cookedPara("[email=eviltrout@mailinator.com]evil trout[/email]", "evil trout", "supports [email] with a title");
assert.cookedPara("[u][i]abc[/i][/u]", "abc", "can nest tags");
assert.cookedPara("[b]first[/b] [b]second[/b]", "firstsecond", "can bold two things on the same line");
});
@@ -655,70 +681,140 @@ QUnit.test("quotes", assert => {
"[quote=\"eviltrout, post:1, topic:2\"]\nthis is <not> a bug\n[/quote]\n\n",
"it escapes the contents of the quote");
- assert.cookedPara("[quote]test[/quote]",
- "",
+ assert.cooked("[quote]\ntest\n[/quote]",
+ "",
"it supports quotes without params");
- assert.cookedPara("[quote]\n*test*\n[/quote]",
- "",
+ assert.cooked("[quote]\n*test*\n[/quote]",
+ "",
"it doesn't insert a new line for italics");
- assert.cookedPara("[quote=,script='a'>", "
hello
", "it sanitizes while cooking");
cooked("disneyreddit",
"
", "hello", "it does not allow centering");
+ cooked("
a\n
\n", "
a\n
", "it does not double sanitize");
cooked("", "", "it does not allow most iframes");
@@ -38,9 +38,9 @@ QUnit.test("sanitize", assert => {
assert.equal(pt.sanitize("