Handle nested content inside links

This commit is contained in:
Christian Muehlhaeuser
2019-11-25 02:40:34 +01:00
parent d082cb2124
commit 6eb2d04812
+15 -5
View File
@@ -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: "",