From 326dc631129ab62ea18542663a502eb82638dcc8 Mon Sep 17 00:00:00 2001 From: Timur Demin Date: Mon, 9 Nov 2020 00:48:54 +0500 Subject: [PATCH] Add support for inline code blocks --- internal/gemini/renderer.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/gemini/renderer.go b/internal/gemini/renderer.go index c6059d1..d4abc01 100644 --- a/internal/gemini/renderer.go +++ b/internal/gemini/renderer.go @@ -175,6 +175,9 @@ func (r Renderer) paragraph(w io.Writer, node *ast.Paragraph, entering bool) (no if text, ok := child.(*ast.Text); ok { r.text(w, text) } + if inlineBlock, ok := child.(*ast.Code); ok { + r.text(w, inlineBlock) + } } if !onlyElementIsLink { w.Write(lineBreak) @@ -244,8 +247,10 @@ func (r Renderer) list(w io.Writer, node *ast.List, level int) { } } -func (r Renderer) text(w io.Writer, node *ast.Text) { - w.Write(node.Literal) +func (r Renderer) text(w io.Writer, node ast.Node) { + if node := node.AsLeaf(); node != nil { + w.Write(node.Literal) + } } // RenderNode implements Renderer.RenderNode().