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:
|
||||
return fmt.Sprintf("<li>%s</li>\n", HTMLFragment(v...))
|
||||
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:
|
||||
return fmt.Sprintf("<p>%s</p>\n", HTMLFragment(v.Elements...))
|
||||
case element.Strong:
|
||||
|
|
|
@ -141,12 +141,12 @@ func TestHTMLFragment(t *testing.T) {
|
|||
element.WhiteSpace(" "),
|
||||
element.Word("text"),
|
||||
element.WhiteSpace("\n"),
|
||||
element.Word("with"),
|
||||
element.Word("<p>with</p>"),
|
||||
element.WhiteSpace("\t"),
|
||||
element.Word("formatting"),
|
||||
},
|
||||
exp: `<pre><code>some text
|
||||
with formatting</code></pre>`,
|
||||
<p>with</p> formatting</code></pre>`,
|
||||
},
|
||||
{
|
||||
name: "subtitle",
|
||||
|
|
Loading…
Reference in New Issue