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.
This commit is contained in:
Timur Demin 2021-08-22 22:51:52 +03:00
parent 4511e4280f
commit c872e012e2
No known key found for this signature in database
GPG key ID: 9EDF3F9D9286FA20

View file

@ -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))