all repos — grayfriday @ 6c330778b2103a689cd94554ed7a5ca83d2888c7

blackfriday fork with a few changes

Merge pull request #214 from russross/issue-122-test-readability

Make test values more readable, add additional test cases.
Vytautas Ĺ altenis vytas@rtfb.lt
Sun, 01 Nov 2015 09:25:47 +0200
commit

6c330778b2103a689cd94554ed7a5ca83d2888c7

parent

15eb452ae4d56122e8f4ddb29f9787345fceff34

1 files changed, 75 insertions(+), 34 deletions(-)

jump to
M block_test.goblock_test.go

@@ -14,6 +14,7 @@

package blackfriday import ( + "strings" "testing" )

@@ -1066,10 +1067,13 @@ doTestsBlock(t, tests, EXTENSION_FENCED_CODE)

} func TestFencedCodeInsideBlockquotes(t *testing.T) { + cat := func(s ...string) string { return strings.Join(s, "\n") } var tests = []string{ - "> ```go\n" + - "package moo\n\n" + - "```\n", + cat("> ```go", + "package moo", + "", + "```", + ""), `<blockquote> <pre><code class="language-go">package moo

@@ -1077,13 +1081,14 @@ </code></pre>

</blockquote> `, // ------------------------------------------- - "> foo\n" + - "> \n" + - "> ```go\n" + - "package moo\n" + - "```\n" + - "> \n" + - "> goo.\n", + cat("> foo", + "> ", + "> ```go", + "package moo", + "```", + "> ", + "> goo.", + ""), `<blockquote> <p>foo</p>

@@ -1094,31 +1099,35 @@ <p>goo.</p>

</blockquote> `, // ------------------------------------------- - "> foo\n" + - "> \n" + - "> quote\n" + - "continues\n" + - "```\n", - "<blockquote>\n" + - "<p>foo</p>\n\n" + - "<p>quote\n" + - "continues\n" + - "```</p>\n" + - "</blockquote>\n", + cat("> foo", + "> ", + "> quote", + "continues", + "```", + ""), + `<blockquote> +<p>foo</p> - "> foo\n" + - "> \n" + - "> ```go\n" + - "package moo\n" + - "```\n" + - "> \n" + - "> goo.\n" + - "> \n" + - "> ```go\n" + - "package zoo\n" + - "```\n" + - "> \n" + - "> woo.\n", +<p>quote +continues +` + "```" + `</p> +</blockquote> +`, + // ------------------------------------------- + cat("> foo", + "> ", + "> ```go", + "package moo", + "```", + "> ", + "> goo.", + "> ", + "> ```go", + "package zoo", + "```", + "> ", + "> woo.", + ""), `<blockquote> <p>foo</p>

@@ -1134,6 +1143,38 @@ <p>woo.</p>

</blockquote> `, } + + // These 2 alternative forms of blockquoted fenced code blocks should produce same output. + forms := [2]string{ + cat("> plain quoted text", + "> ```fenced", + "code", + " with leading single space correctly preserved", + "okay", + "```", + "> rest of quoted text"), + cat("> plain quoted text", + "> ```fenced", + "> code", + "> with leading single space correctly preserved", + "> okay", + "> ```", + "> rest of quoted text"), + } + want := `<blockquote> +<p>plain quoted text</p> + +<pre><code class="language-fenced">code + with leading single space correctly preserved +okay +</code></pre> + +<p>rest of quoted text</p> +</blockquote> +` + tests = append(tests, forms[0], want) + tests = append(tests, forms[1], want) + doTestsBlock(t, tests, EXTENSION_FENCED_CODE) }