markdown
markdown copied to clipboard
Code Block classes overwriting when language is annotated
Hello guys! I found a bug with CodeBlock rendering. I want to add my own Class to the CodeBlock node so I add it like this:
node.Attribute = &ast.Attribute{
Classes: [][]byte{[]byte("my-class")},
}
But when a specific language is annotated in the code block in the md
```yml
text: something
another-text:
depth: asd
Renderer overwrite my class and final result is this :
<pre><code class="language-yml">
text: something
another-text:
depth: asd
</code></pre>
But should be this or something similar
<pre><code class="language-yml my-class">
text: something
another-text:
depth: asd
</code></pre>
known bug - but should be fixed at some point:
// CodeBlock writes ast.CodeBlock node
func (r *Renderer) CodeBlock(w io.Writer, codeBlock *ast.CodeBlock) {
var attrs []string
// TODO(miek): this can add multiple class= attribute, they should be coalesced into one.
// This is probably true for some other elements as well
attrs = appendLanguageAttr(attrs, codeBlock.Info)
see html/renderer.go