all repos — grayfriday @ ad246ef7a5fcb5c3a14cb874ce67ee5f82a13bbd

blackfriday fork with a few changes

Don't expand tabs inside fenced code blocks.

Still do normalize newlines inside fenced code blocks.
Dmitri Shuralyov shurcooL@gmail.com
Sat, 12 Apr 2014 14:45:25 -0700
commit

ad246ef7a5fcb5c3a14cb874ce67ee5f82a13bbd

parent

8df342acd510645e8bbc608a209e788edd2667d6

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')