diff --git a/block_test.go b/block_test.go index c320edd..3c37202 100644 --- a/block_test.go +++ b/block_test.go @@ -638,7 +638,7 @@ func TestPreformattedHtmlLax(t *testing.T) { func TestFencedCodeBlock(t *testing.T) { var tests = []string{ "``` go\nfunc foo() bool {\n\treturn true;\n}\n```\n", - "
func foo() bool {\n    return true;\n}\n
\n", + "
func foo() bool {\n\treturn true;\n}\n
\n", "``` c\n/* special & char < > \" escaping */\n```\n", "
/* special & char < > " escaping */\n
\n", @@ -978,7 +978,7 @@ func TestOrderedList_EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK(t *testing.T) { func TestFencedCodeBlock_EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK(t *testing.T) { var tests = []string{ "``` go\nfunc foo() bool {\n\treturn true;\n}\n```\n", - "
func foo() bool {\n    return true;\n}\n
\n", + "
func foo() bool {\n\treturn true;\n}\n
\n", "``` c\n/* special & char < > \" escaping */\n```\n", "
/* special & char < > " escaping */\n
\n", diff --git a/markdown.go b/markdown.go index 33f36b2..02e486d 100644 --- a/markdown.go +++ b/markdown.go @@ -343,7 +343,11 @@ func firstPass(p *parser, input []byte) []byte { // 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')