mirror of
https://github.com/rwinkhart/glamour-temp-MUTN.git
synced 2026-09-06 00:47:15 -04:00
Handle nested content inside links
This commit is contained in:
@@ -221,14 +221,22 @@ func NewElement(node *bf.Node) Element {
|
|||||||
Style: Del,
|
Style: Del,
|
||||||
}},
|
}},
|
||||||
}
|
}
|
||||||
|
|
||||||
case bf.Link:
|
case bf.Link:
|
||||||
f := []Fragment{}
|
f := []Fragment{}
|
||||||
|
|
||||||
|
if node.LastChild != nil {
|
||||||
|
if node.LastChild.Type == bf.Image {
|
||||||
|
el := NewElement(node.LastChild)
|
||||||
|
f = el.Fragments
|
||||||
|
}
|
||||||
if len(node.LastChild.Literal) > 0 {
|
if len(node.LastChild.Literal) > 0 {
|
||||||
f = append(f, Fragment{
|
f = append(f, Fragment{
|
||||||
Token: string(node.LastChild.Literal),
|
Token: string(node.LastChild.Literal),
|
||||||
Style: LinkText,
|
Style: LinkText,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if len(node.LinkData.Destination) > 0 {
|
if len(node.LinkData.Destination) > 0 {
|
||||||
f = append(f, Fragment{
|
f = append(f, Fragment{
|
||||||
Token: string(node.LinkData.Destination),
|
Token: string(node.LinkData.Destination),
|
||||||
@@ -243,6 +251,7 @@ func NewElement(node *bf.Node) Element {
|
|||||||
Post: "",
|
Post: "",
|
||||||
Fragments: f,
|
Fragments: f,
|
||||||
}
|
}
|
||||||
|
|
||||||
case bf.Image:
|
case bf.Image:
|
||||||
f := []Fragment{}
|
f := []Fragment{}
|
||||||
if len(node.LastChild.Literal) > 0 {
|
if len(node.LastChild.Literal) > 0 {
|
||||||
@@ -265,6 +274,7 @@ func NewElement(node *bf.Node) Element {
|
|||||||
Post: "",
|
Post: "",
|
||||||
Fragments: f,
|
Fragments: f,
|
||||||
}
|
}
|
||||||
|
|
||||||
case bf.Text:
|
case bf.Text:
|
||||||
return Element{
|
return Element{
|
||||||
Pre: "",
|
Pre: "",
|
||||||
|
|||||||
Reference in New Issue
Block a user