all repos — grayfriday @ 15eb452ae4d56122e8f4ddb29f9787345fceff34

blackfriday fork with a few changes

Fix fenced code processing inside blockquotes

Add a call to fenced code block processor inside the loop that's
responsible for collecting the quoted lines. Grok all the fenced code
block as a part of the quoted text.

Closes #122.
Vytautas Ĺ altenis vytas@rtfb.lt
Thu, 29 Oct 2015 20:06:27 +0200
commit

15eb452ae4d56122e8f4ddb29f9787345fceff34

parent

607f2ceb8a9183899fcc3026d23f115d733bad07

2 files changed, 82 insertions(+), 0 deletions(-)

jump to
M block.goblock.go

@@ -909,7 +909,17 @@ var raw bytes.Buffer

beg, end := 0, 0 for beg < len(data) { end = beg + // Step over whole lines, collecting them. While doing that, check for + // fenced code and if one's found, incorporate it altogether, + // irregardless of any contents inside it for data[end] != '\n' { + if p.flags&EXTENSION_FENCED_CODE != 0 { + if i := p.fencedCode(out, data[end:], false); i > 0 { + // -1 to compensate for the extra end++ after the loop: + end += i - 1 + break + } + } end++ } end++
M block_test.goblock_test.go

@@ -1065,6 +1065,78 @@ }

doTestsBlock(t, tests, EXTENSION_FENCED_CODE) } +func TestFencedCodeInsideBlockquotes(t *testing.T) { + var tests = []string{ + "> ```go\n" + + "package moo\n\n" + + "```\n", + `<blockquote> +<pre><code class="language-go">package moo + +</code></pre> +</blockquote> +`, + // ------------------------------------------- + "> foo\n" + + "> \n" + + "> ```go\n" + + "package moo\n" + + "```\n" + + "> \n" + + "> goo.\n", + `<blockquote> +<p>foo</p> + +<pre><code class="language-go">package moo +</code></pre> + +<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", + + "> foo\n" + + "> \n" + + "> ```go\n" + + "package moo\n" + + "```\n" + + "> \n" + + "> goo.\n" + + "> \n" + + "> ```go\n" + + "package zoo\n" + + "```\n" + + "> \n" + + "> woo.\n", + `<blockquote> +<p>foo</p> + +<pre><code class="language-go">package moo +</code></pre> + +<p>goo.</p> + +<pre><code class="language-go">package zoo +</code></pre> + +<p>woo.</p> +</blockquote> +`, + } + doTestsBlock(t, tests, EXTENSION_FENCED_CODE) +} + func TestTable(t *testing.T) { var tests = []string{ "a | b\n---|---\nc | d\n",