Skip to content

Commit

Permalink
Fix rendering of links as first paragraph child
Browse files Browse the repository at this point in the history
Fixes #2.
  • Loading branch information
tdemin committed Nov 11, 2020
1 parent b181afc commit ceed6f0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/gemini/renderer.go
Expand Up @@ -150,8 +150,8 @@ func (r Renderer) paragraph(w io.Writer, node *ast.Paragraph, entering bool) (no
// current version of gomarkdown/markdown finds an empty
// *ast.Text element before links/images, breaking the heuristic
onlyElementWithGoMarkdownFix := func() bool {
if len(node.Children) > 1 {
firstChild := node.Children[0]
if len(children) == 2 {
firstChild := children[0]
_, elementIsText := firstChild.(*ast.Text)
asLeaf := firstChild.AsLeaf()
if elementIsText && asLeaf != nil && len(asLeaf.Literal) == 0 {
Expand All @@ -163,7 +163,7 @@ func (r Renderer) paragraph(w io.Writer, node *ast.Paragraph, entering bool) (no
}()
onlyElement := len(children) == 1 || onlyElementWithGoMarkdownFix
onlyElementIsLink := func() bool {
if len(children) >= 1 {
if len(children) == 1 {
if _, ok := children[0].(*ast.Link); ok {
return true
}
Expand Down

0 comments on commit ceed6f0

Please sign in to comment.