From d3e8276e6e63fc5bf1d7814d7cb0c246e652f837 Mon Sep 17 00:00:00 2001 From: mntn <85877297+mntn-xyz@users.noreply.github.com> Date: Sat, 21 Aug 2021 18:38:50 -0400 Subject: [PATCH] Add info string for fenced code blocks --- internal/gemini/renderer.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/gemini/renderer.go b/internal/gemini/renderer.go index 39702ec..dd98823 100644 --- a/internal/gemini/renderer.go +++ b/internal/gemini/renderer.go @@ -37,7 +37,7 @@ var ( quotePrefix = []byte("> ") itemPrefix = []byte("* ") itemIndent = []byte{'\t'} - preformattedToggle = []byte("```\n") + preformattedToggle = []byte("```") ) var meaningfulCharsRegex = regexp.MustCompile(`\A[\s]+\z`) @@ -206,8 +206,13 @@ func (r Renderer) paragraph(w io.Writer, node *ast.Paragraph, entering bool) (no func (r Renderer) code(w io.Writer, node *ast.CodeBlock) { w.Write(preformattedToggle) + if node.IsFenced { + w.Write(node.Info) + } + w.Write(lineBreak) w.Write(node.Literal) w.Write(preformattedToggle) + w.Write(lineBreak) } func (r Renderer) list(w io.Writer, node *ast.List, level int) { @@ -325,6 +330,7 @@ func (r Renderer) tableBody(t *tablewriter.Table, node *ast.TableBody) { func (r Renderer) table(w io.Writer, node *ast.Table, entering bool) { if entering { w.Write(preformattedToggle) + w.Write(lineBreak) // gomarkdown appears to only parse headings consisting of a // single line and always have a TableBody preceded by a single // TableHeader but we're better off not relying on it @@ -343,6 +349,7 @@ func (r Renderer) table(w io.Writer, node *ast.Table, entering bool) { t.Render() } else { w.Write(preformattedToggle) + w.Write(lineBreak) } }