mirror of
https://github.com/rwinkhart/glamour-temp-MUTN.git
synced 2026-09-05 16:37:19 -04:00
Use a Renderer interface instead of rendering fragments
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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: Image,
|
||||
}
|
||||
el.Render(w, node.LastChild, tr)
|
||||
}
|
||||
if len(node.LinkData.Destination) > 0 {
|
||||
el := &BaseElement{
|
||||
Token: resolveRelativeURL(tr.BaseURL, string(node.LinkData.Destination)),
|
||||
Pre: " [Image: ",
|
||||
Post: "]",
|
||||
Style: Link,
|
||||
}
|
||||
el.Render(w, node, tr)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user