Add !!!figure tag to ggcode

This commit is contained in:
Ben Visness 2022-10-08 17:28:02 -05:00
parent 3d7c095c87
commit b5dac2f4d8
2 changed files with 21 additions and 0 deletions

Binary file not shown.

View File

@ -78,6 +78,27 @@ var ggcodeTags = map[string]ggcodeTag{
return nil return nil
}, },
}, },
"figure": {
Filter: ggcodeFilterEdu,
Renderer: func(c ggcodeRendererContext, n *ggcodeNode, entering bool) error {
if entering {
c.W.WriteString(`<figure>`)
var srcAttr, altAttr string
if src := n.Args["src"]; src != "" {
srcAttr = fmt.Sprintf(` src="%s"`, src)
}
if alt := n.Args["alt"]; alt != "" {
altAttr = fmt.Sprintf(` alt="%s"`, alt)
}
c.W.WriteString(fmt.Sprintf(`<img%s%s>`, srcAttr, altAttr))
c.W.WriteString(`<figcaption>`)
} else {
c.W.WriteString(`</figcaption>`)
c.W.WriteString(`</figure>`)
}
return nil
},
},
} }
// ---------------------- // ----------------------