diff --git a/parser/fcode_block.go b/parser/fcode_block.go index f5b83ee..9cef7c7 100644 --- a/parser/fcode_block.go +++ b/parser/fcode_block.go @@ -63,6 +63,20 @@ func (b *fencedCodeBlockParser) Open(parent ast.Node, reader text.Reader, pc Con } } node := ast.NewFencedCodeBlock(info) + // add attributes + if info != nil { + infoText := info.Text(reader.Source()) + pos := bytes.IndexByte(infoText, '{') + if pos > -1 { + attrs, ok := ParseAttributes(text.NewReader(infoText[pos:])) + if ok { + for _, attr := range attrs { + node.SetAttribute(attr.Name, attr.Value) + } + } + } + } + pc.Set(fencedCodeBlockInfoKey, &fenceData{fenceChar, findent, oFenceLength, node}) return node, NoChildren diff --git a/renderer/html/html.go b/renderer/html/html.go index 8134b8b..b24713e 100644 --- a/renderer/html/html.go +++ b/renderer/html/html.go @@ -274,7 +274,11 @@ func (r *Renderer) renderCodeBlock(w util.BufWriter, source []byte, n ast.Node, func (r *Renderer) renderFencedCodeBlock(w util.BufWriter, source []byte, node ast.Node, entering bool) (ast.WalkStatus, error) { n := node.(*ast.FencedCodeBlock) if entering { - _, _ = w.WriteString("