mirror of
https://github.com/rwinkhart/glamour-temp-MUTN.git
synced 2026-08-28 04:46:29 -04:00
37 lines
679 B
Go
37 lines
679 B
Go
package gold
|
|
|
|
import (
|
|
"io"
|
|
|
|
bf "gopkg.in/russross/blackfriday.v2"
|
|
)
|
|
|
|
type ImageElement struct {
|
|
}
|
|
|
|
func (e *ImageElement) Render(w io.Writer, node *bf.Node, tr *TermRenderer) error {
|
|
if len(node.LastChild.Literal) > 0 {
|
|
el := &BaseElement{
|
|
Token: string(node.LastChild.Literal),
|
|
Style: tr.style[ImageText],
|
|
}
|
|
err := el.Render(w, node.LastChild, tr)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
if len(node.LinkData.Destination) > 0 {
|
|
el := &BaseElement{
|
|
Token: resolveRelativeURL(tr.BaseURL, string(node.LinkData.Destination)),
|
|
Prefix: " ",
|
|
Style: tr.style[Image],
|
|
}
|
|
err := el.Render(w, node, tr)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|