mirror of
https://github.com/rwinkhart/glamour-temp-MUTN.git
synced 2026-08-28 04:46:29 -04:00
39 lines
600 B
Go
39 lines
600 B
Go
package gold
|
|
|
|
import (
|
|
"io"
|
|
)
|
|
|
|
type ImageElement struct {
|
|
Text string
|
|
BaseURL string
|
|
URL string
|
|
Child ElementRenderer // FIXME
|
|
}
|
|
|
|
func (e *ImageElement) Render(w io.Writer, ctx RenderContext) error {
|
|
if len(e.Text) > 0 {
|
|
el := &BaseElement{
|
|
Token: e.Text,
|
|
Style: ctx.styles.ImageText,
|
|
}
|
|
err := el.Render(w, ctx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
if len(e.URL) > 0 {
|
|
el := &BaseElement{
|
|
Token: resolveRelativeURL(e.BaseURL, e.URL),
|
|
Prefix: " ",
|
|
Style: ctx.styles.Image,
|
|
}
|
|
err := el.Render(w, ctx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|