From c872e012e2bac351fc1c403d533db5ab35d32ab2 Mon Sep 17 00:00:00 2001 From: Timur Demin Date: Sun, 22 Aug 2021 22:51:52 +0300 Subject: [PATCH] Enable gomarkdown's NoEmptyLineBeforeBlock rule This changes gomarkdown parser behavior to allow code blocks, lists, etc to come after other blocks (like paragraphs) and get processed as independent blocks without a separate newline (putting gomarkdown in charge to decide whether a new block is started). This is a breaking change as this affects how some existing Markdown source might get rendered. Nonetheless, this is probably the expected default by most users. This has no configurable switch yet. See #14. --- render.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/render.go b/render.go index a608e8c..93c68b7 100644 --- a/render.go +++ b/render.go @@ -101,7 +101,7 @@ func RenderMarkdown(md []byte, settings Settings) (geminiText []byte, metadata H } md = md[blockEnd+len(yamlDelimiter)*2:] parse: - ast := markdown.Parse(md, parser.NewWithExtensions(parser.CommonExtensions)) + ast := markdown.Parse(md, parser.NewWithExtensions(parser.CommonExtensions|parser.NoEmptyLineBeforeBlock)) var content []byte if settings.Has(WithMetadata) && metadata.PostTitle != "" { content = markdown.Render(ast, gemini.NewRendererWithMetadata(metadata))