mirror of
https://github.com/rwinkhart/glamour-temp-MUTN.git
synced 2026-09-05 16:37:19 -04:00
Move ANSIRenderer into a separate package
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package ansi
|
||||
|
||||
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.options.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.options.Styles.Image,
|
||||
}
|
||||
err := el.Render(w, ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user