From 2fac8a6353e46c3738017b38ca4e14f3e30fd39f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Bohusl=C3=A1vek?= Date: Thu, 26 Jun 2025 10:18:49 +0200 Subject: [PATCH] markdown: ensure blank line before quote and table blocks Fixes #23 --- quote.go | 1 + table.go | 1 + testdata/basic_fmt.txt | 1 + testdata/table_fmt.txt | 7 +++++++ 4 files changed, 10 insertions(+) diff --git a/quote.go b/quote.go index c662af5..6a63b33 100644 --- a/quote.go +++ b/quote.go @@ -23,6 +23,7 @@ func (b *Quote) printHTML(p *printer) { } func (b *Quote) printMarkdown(p *printer) { + p.maybeNL() p.maybeQuoteNL('>') p.WriteString("> ") defer p.pop(p.push("> ")) diff --git a/table.go b/table.go index 8348f22..1779a11 100644 --- a/table.go +++ b/table.go @@ -93,6 +93,7 @@ func (t *Table) printMarkdown(p *printer) { rows = append(rows, xrow) } + p.maybeNL() p.maybeQuoteNL('|') for i, cell := range hdr { p.WriteString("| ") diff --git a/testdata/basic_fmt.txt b/testdata/basic_fmt.txt index 2af285b..c5aa8a3 100644 --- a/testdata/basic_fmt.txt +++ b/testdata/basic_fmt.txt @@ -229,6 +229,7 @@ placed within the reach of poodles. The end. -- want -- As Celine said: + > Love is the infinite > placed within the reach of poodles. diff --git a/testdata/table_fmt.txt b/testdata/table_fmt.txt index 0d9b737..a7e9029 100644 --- a/testdata/table_fmt.txt +++ b/testdata/table_fmt.txt @@ -41,3 +41,10 @@ | --- | -------- | --- | | 1 | 22345678 | 3 | | a | b | c | +-- preceding text -- +Text. + +| foo | bar | baz | +| --- | -------- | --- | +| 1 | 22345678 | 3 | +| a | b | c |