fix html in code block formatting
This commit is contained in:
parent
e1d454085a
commit
04244d682a
|
@ -47,7 +47,7 @@ func htmlElement(el element.Element) string {
|
||||||
case element.ListItem:
|
case element.ListItem:
|
||||||
return fmt.Sprintf("<li>%s</li>\n", HTMLFragment(v...))
|
return fmt.Sprintf("<li>%s</li>\n", HTMLFragment(v...))
|
||||||
case element.CodeBlock:
|
case element.CodeBlock:
|
||||||
return fmt.Sprintf("<pre><code>%s</code></pre>", v.Text())
|
return fmt.Sprintf("<pre><code>%s</code></pre>", html.EscapeString(v.Text()))
|
||||||
case element.Paragraph:
|
case element.Paragraph:
|
||||||
return fmt.Sprintf("<p>%s</p>\n", HTMLFragment(v.Elements...))
|
return fmt.Sprintf("<p>%s</p>\n", HTMLFragment(v.Elements...))
|
||||||
case element.Strong:
|
case element.Strong:
|
||||||
|
|
|
@ -141,12 +141,12 @@ func TestHTMLFragment(t *testing.T) {
|
||||||
element.WhiteSpace(" "),
|
element.WhiteSpace(" "),
|
||||||
element.Word("text"),
|
element.Word("text"),
|
||||||
element.WhiteSpace("\n"),
|
element.WhiteSpace("\n"),
|
||||||
element.Word("with"),
|
element.Word("<p>with</p>"),
|
||||||
element.WhiteSpace("\t"),
|
element.WhiteSpace("\t"),
|
||||||
element.Word("formatting"),
|
element.Word("formatting"),
|
||||||
},
|
},
|
||||||
exp: `<pre><code>some text
|
exp: `<pre><code>some text
|
||||||
with formatting</code></pre>`,
|
<p>with</p> formatting</code></pre>`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "subtitle",
|
name: "subtitle",
|
||||||
|
|
Loading…
Reference in New Issue