mirror of
https://github.com/charmbracelet/glow.git
synced 2026-08-24 00:54:17 +02:00
Handle nested content inside links
This commit is contained in:
parent
b600bc47ef
commit
b289f59056
1 changed files with 15 additions and 5 deletions
20
gold.go
20
gold.go
|
|
@ -221,13 +221,21 @@ func NewElement(node *bf.Node) Element {
|
|||
Style: Del,
|
||||
}},
|
||||
}
|
||||
|
||||
case bf.Link:
|
||||
f := []Fragment{}
|
||||
if len(node.LastChild.Literal) > 0 {
|
||||
f = append(f, Fragment{
|
||||
Token: string(node.LastChild.Literal),
|
||||
Style: LinkText,
|
||||
})
|
||||
|
||||
if node.LastChild != nil {
|
||||
if node.LastChild.Type == bf.Image {
|
||||
el := NewElement(node.LastChild)
|
||||
f = el.Fragments
|
||||
}
|
||||
if len(node.LastChild.Literal) > 0 {
|
||||
f = append(f, Fragment{
|
||||
Token: string(node.LastChild.Literal),
|
||||
Style: LinkText,
|
||||
})
|
||||
}
|
||||
}
|
||||
if len(node.LinkData.Destination) > 0 {
|
||||
f = append(f, Fragment{
|
||||
|
|
@ -243,6 +251,7 @@ func NewElement(node *bf.Node) Element {
|
|||
Post: "",
|
||||
Fragments: f,
|
||||
}
|
||||
|
||||
case bf.Image:
|
||||
f := []Fragment{}
|
||||
if len(node.LastChild.Literal) > 0 {
|
||||
|
|
@ -265,6 +274,7 @@ func NewElement(node *bf.Node) Element {
|
|||
Post: "",
|
||||
Fragments: f,
|
||||
}
|
||||
|
||||
case bf.Text:
|
||||
return Element{
|
||||
Pre: "",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue