Disabled formatting in inline codes
This commit is contained in:
parent
9e6767fb12
commit
1c7f9f2f7d
23
Render.go
23
Render.go
@ -253,7 +253,6 @@ func (r *renderer) writeText(markdown string) {
|
|||||||
searchStart = 0
|
searchStart = 0
|
||||||
linkTextStart = -1
|
linkTextStart = -1
|
||||||
linkTextEnd = -1
|
linkTextEnd = -1
|
||||||
codeStart = -1
|
|
||||||
emStart = -1
|
emStart = -1
|
||||||
strongStart = -1
|
strongStart = -1
|
||||||
strikeStart = -1
|
strikeStart = -1
|
||||||
@ -324,18 +323,20 @@ begin:
|
|||||||
}
|
}
|
||||||
|
|
||||||
case '`':
|
case '`':
|
||||||
if codeStart != -1 {
|
end := strings.IndexByte(markdown[searchStart:], '`')
|
||||||
r.WriteString("<code>")
|
|
||||||
r.WriteString(html.EscapeString(markdown[codeStart:i]))
|
if end == -1 {
|
||||||
r.WriteString("</code>")
|
continue
|
||||||
codeStart = -1
|
|
||||||
tokenStart = i + 1
|
|
||||||
} else {
|
|
||||||
r.WriteString(html.EscapeString(markdown[tokenStart:i]))
|
|
||||||
tokenStart = i
|
|
||||||
codeStart = i + 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r.WriteString(html.EscapeString(markdown[tokenStart:i]))
|
||||||
|
r.WriteString("<code>")
|
||||||
|
r.WriteString(html.EscapeString(markdown[searchStart : searchStart+end]))
|
||||||
|
r.WriteString("</code>")
|
||||||
|
|
||||||
|
searchStart += end + 1
|
||||||
|
tokenStart = searchStart
|
||||||
|
|
||||||
case '*', '_':
|
case '*', '_':
|
||||||
if i == emStart {
|
if i == emStart {
|
||||||
strongStart = i + 1
|
strongStart = i + 1
|
||||||
|
@ -70,6 +70,7 @@ func TestCode(t *testing.T) {
|
|||||||
assert.Equal(t, markdown.Render("```\nText\n```"), "<pre><code>Text</code></pre>")
|
assert.Equal(t, markdown.Render("```\nText\n```"), "<pre><code>Text</code></pre>")
|
||||||
assert.Equal(t, markdown.Render("```go\ntype A struct {\n\t\n}\n```"), "<pre><code class=\"language-go\">type A struct {\n\t\n}</code></pre>")
|
assert.Equal(t, markdown.Render("```go\ntype A struct {\n\t\n}\n```"), "<pre><code class=\"language-go\">type A struct {\n\t\n}</code></pre>")
|
||||||
assert.Equal(t, markdown.Render("`monospace`"), "<p><code>monospace</code></p>")
|
assert.Equal(t, markdown.Render("`monospace`"), "<p><code>monospace</code></p>")
|
||||||
|
assert.Equal(t, markdown.Render("`unfinished"), "<p>`unfinished</p>")
|
||||||
assert.Equal(t, markdown.Render("Inline `monospace` text."), "<p>Inline <code>monospace</code> text.</p>")
|
assert.Equal(t, markdown.Render("Inline `monospace` text."), "<p>Inline <code>monospace</code> text.</p>")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user