1
0
mirror of https://github.com/danog/blackfriday.git synced 2024-11-30 04:29:13 +01:00

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

Don't expand tabs inside fenced code blocks.
This commit is contained in:
Vytautas Šaltenis 2014-04-13 10:56:02 +03:00
commit 9c7cf8b1b7
2 changed files with 7 additions and 3 deletions

View File

@ -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",
"<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 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",
"<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",

View File

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