mirror of
https://github.com/status-im/markdown.git
synced 2025-02-23 16:48:14 +00:00
Don't expand tabs inside fenced code blocks.
Still do normalize newlines inside fenced code blocks.
This commit is contained in:
parent
8df342acd5
commit
ad246ef7a5
@ -638,7 +638,7 @@ func TestPreformattedHtmlLax(t *testing.T) {
|
|||||||
func TestFencedCodeBlock(t *testing.T) {
|
func TestFencedCodeBlock(t *testing.T) {
|
||||||
var tests = []string{
|
var tests = []string{
|
||||||
"``` go\nfunc foo() bool {\n\treturn true;\n}\n```\n",
|
"``` 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",
|
"``` c\n/* special & char < > \" escaping */\n```\n",
|
||||||
"<pre><code class=\"c\">/* special & char < > " escaping */\n</code></pre>\n",
|
"<pre><code class=\"c\">/* special & char < > " 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) {
|
func TestFencedCodeBlock_EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK(t *testing.T) {
|
||||||
var tests = []string{
|
var tests = []string{
|
||||||
"``` go\nfunc foo() bool {\n\treturn true;\n}\n```\n",
|
"``` 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",
|
"``` c\n/* special & char < > \" escaping */\n```\n",
|
||||||
"<pre><code class=\"c\">/* special & char < > " escaping */\n</code></pre>\n",
|
"<pre><code class=\"c\">/* special & char < > " escaping */\n</code></pre>\n",
|
||||||
|
@ -343,7 +343,11 @@ func firstPass(p *parser, input []byte) []byte {
|
|||||||
|
|
||||||
// add the line body if present
|
// add the line body if present
|
||||||
if end > beg {
|
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')
|
out.WriteByte('\n')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user