all repos — grayfriday @ 9c7cf8b1b7ce43e76f0cf9bc1ebf3fb7430bc5ea

blackfriday fork with a few changes

Merge pull request #61 from shurcooL/feature/dont-expand-tabs-inside-fenced-code-blocks

Don't expand tabs inside fenced code blocks.
Vytautas Ĺ altenis vytas@rtfb.lt
Sun, 13 Apr 2014 10:56:02 +0300
commit

9c7cf8b1b7ce43e76f0cf9bc1ebf3fb7430bc5ea

parent

5bcdd5eb7f81a9db3e4e08ef88f150c4e70917c3

2 files changed, 7 insertions(+), 3 deletions(-)

jump to
M block_test.goblock_test.go

@@ -638,7 +638,7 @@

func TestFencedCodeBlock(t *testing.T) { var tests = []string{ "``` go\nfunc foo() bool {\n\treturn true;\n}\n```\n", - "<pre><code class=\"go\">func foo() bool {\n return true;\n}\n</code></pre>\n", + "<pre><code class=\"go\">func foo() bool {\n\treturn true;\n}\n</code></pre>\n", "``` c\n/* special & char < > \" escaping */\n```\n", "<pre><code class=\"c\">/* special &amp; char &lt; &gt; &quot; escaping */\n</code></pre>\n",

@@ -978,7 +978,7 @@

func TestFencedCodeBlock_EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK(t *testing.T) { var tests = []string{ "``` go\nfunc foo() bool {\n\treturn true;\n}\n```\n", - "<pre><code class=\"go\">func foo() bool {\n return true;\n}\n</code></pre>\n", + "<pre><code class=\"go\">func foo() bool {\n\treturn true;\n}\n</code></pre>\n", "``` c\n/* special & char < > \" escaping */\n```\n", "<pre><code class=\"c\">/* special &amp; char &lt; &gt; &quot; escaping */\n</code></pre>\n",
M markdown.gomarkdown.go

@@ -343,7 +343,11 @@ }

// add the line body if present if end > beg { - expandTabs(&out, input[beg:end], tabSize) + if end < lastFencedCodeBlockEnd { // Do not expand tabs while inside fenced code blocks. + out.Write(input[beg:end]) + } else { + expandTabs(&out, input[beg:end], tabSize) + } } out.WriteByte('\n')