Repository: kovetskiy/mark
Pull request #471 (2024-07-25 20:25:23)

Do not render paragraph tags
If we stop rendering paragraphs, then macros that surround text will actually work.

Likely a breaking change and will bump the package to v10.

mrueg: @OnceUponALoop this likely help with #466 as well.

Patch:
diff --git a/pkg/mark/link.go b/pkg/mark/link.go
index 0c162ee..c107c64 100644
--- a/pkg/mark/link.go
+++ b/pkg/mark/link.go
@@ -203,9 +203,9 @@ func getConfluenceLink(
 	}
 
 	if page != nil {
-		// Confluence supports relative links to reference other pages:
-		// https://confluence.atlassian.com/doc/links-776656293.html
-		link = page.Links.Full
+		// Needs baseURL, as REST api response URL doesn't contain subpath ir
+		// confluence is server from that
+		link = api.BaseURL + page.Links.Full
 	}
 
 	return link, nil
diff --git a/pkg/mark/markdown.go b/pkg/mark/markdown.go
index 2f057d3..b1c58cd 100644
--- a/pkg/mark/markdown.go
+++ b/pkg/mark/markdown.go
@@ -58,6 +58,7 @@ func (c *ConfluenceExtension) Extend(m goldmark.Markdown) {
 		util.Prioritized(crenderer.NewConfluenceHTMLBlockRenderer(c.Stdlib), 100),
 		util.Prioritized(crenderer.NewConfluenceHeadingRenderer(c.DropFirstH1), 100),
 		util.Prioritized(crenderer.NewConfluenceImageRenderer(c.Stdlib, c, c.Path), 100),
+		util.Prioritized(crenderer.NewConfluenceParagraphRenderer(), 100),
 		util.Prioritized(crenderer.NewConfluenceLinkRenderer(), 100),
 	))
 
diff --git a/pkg/mark/renderer/paragraph.go b/pkg/mark/renderer/paragraph.go
new file mode 100644
index 0000000..df9bc49
--- /dev/null
+++ b/pkg/mark/renderer/paragraph.go
@@ -0,0 +1,31 @@
+package renderer
+
+import (
+	"github.com/yuin/goldmark/ast"
+	"github.com/yuin/goldmark/renderer"
+	"github.com/yuin/goldmark/renderer/html"
+	"github.com/yuin/goldmark/util"
+)
+
+type ConfluenceParagraphRenderer struct {
+	html.Config
+}
+
+// NewConfluenceRenderer creates a new instance of the ConfluenceRenderer
+func NewConfluenceParagraphRenderer(opts ...html.Option) renderer.NodeRenderer {
+	return &ConfluenceParagraphRenderer{
+		Config: html.NewConfig(),
+	}
+}
+
+// RegisterFuncs implements NodeRenderer.RegisterFuncs .
+func (r *ConfluenceParagraphRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer) {
+	reg.Register(ast.KindParagraph, r.renderParagraph)
+}
+
+func (r *ConfluenceParagraphRenderer) renderParagraph(w util.BufWriter, source []byte, n ast.Node, entering bool) (ast.WalkStatus, error) {
+	if !entering {
+		_, _ = w.WriteString("\n")
+	}
+	return ast.WalkContinue, nil
+}


Test patch:
diff --git a/pkg/mark/testdata/codes-droph1.html b/pkg/mark/testdata/codes-droph1.html
index 733410b..bcf5be7 100644
--- a/pkg/mark/testdata/codes-droph1.html
+++ b/pkg/mark/testdata/codes-droph1.html
@@ -1,7 +1,7 @@
-<p><code>inline</code></p>
+<code>inline</code>
 <ac:structured-macro ac:name="code"><ac:parameter ac:name="language"></ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[some code]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">bash</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[code bash]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">bash</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[with a newline
-]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">unknown</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[unknown code]]></ac:plain-text-body></ac:structured-macro><p>text
-text 2</p>
+]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">unknown</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[unknown code]]></ac:plain-text-body></ac:structured-macro>text
+text 2
 <ac:structured-macro ac:name="code"><ac:parameter ac:name="language">unknown</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[unknown code 2]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">sh</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:parameter ac:name="title">A b c</ac:parameter><ac:plain-text-body><![CDATA[no-collapse-title]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">bash</ac:parameter><ac:parameter ac:name="collapse">true</ac:parameter><ac:parameter ac:name="title">A b c</ac:parameter><ac:plain-text-body><![CDATA[collapse-and-title]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">c</ac:parameter><ac:parameter ac:name="collapse">true</ac:parameter><ac:plain-text-body><![CDATA[collapse-no-title]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">nested</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[code
 ``` more code ```
 even more code]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language"></ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[indented code block
diff --git a/pkg/mark/testdata/codes-stripnewlines.html b/pkg/mark/testdata/codes-stripnewlines.html
index 63eff28..35097f5 100644
--- a/pkg/mark/testdata/codes-stripnewlines.html
+++ b/pkg/mark/testdata/codes-stripnewlines.html
@@ -1,6 +1,6 @@
-<p><code>inline</code></p>
+<code>inline</code>
 <ac:structured-macro ac:name="code"><ac:parameter ac:name="language"></ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[some code]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">bash</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[code bash]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">bash</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[with a newline
-]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">unknown</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[unknown code]]></ac:plain-text-body></ac:structured-macro><p>text text 2</p>
+]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">unknown</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[unknown code]]></ac:plain-text-body></ac:structured-macro>text text 2
 <ac:structured-macro ac:name="code"><ac:parameter ac:name="language">unknown</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[unknown code 2]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">sh</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:parameter ac:name="title">A b c</ac:parameter><ac:plain-text-body><![CDATA[no-collapse-title]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">bash</ac:parameter><ac:parameter ac:name="collapse">true</ac:parameter><ac:parameter ac:name="title">A b c</ac:parameter><ac:plain-text-body><![CDATA[collapse-and-title]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">c</ac:parameter><ac:parameter ac:name="collapse">true</ac:parameter><ac:plain-text-body><![CDATA[collapse-no-title]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">nested</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[code
 ``` more code ```
 even more code]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language"></ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[indented code block
diff --git a/pkg/mark/testdata/codes.html b/pkg/mark/testdata/codes.html
index 733410b..bcf5be7 100644
--- a/pkg/mark/testdata/codes.html
+++ b/pkg/mark/testdata/codes.html
@@ -1,7 +1,7 @@
-<p><code>inline</code></p>
+<code>inline</code>
 <ac:structured-macro ac:name="code"><ac:parameter ac:name="language"></ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[some code]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">bash</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[code bash]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">bash</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[with a newline
-]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">unknown</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[unknown code]]></ac:plain-text-body></ac:structured-macro><p>text
-text 2</p>
+]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">unknown</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[unknown code]]></ac:plain-text-body></ac:structured-macro>text
+text 2
 <ac:structured-macro ac:name="code"><ac:parameter ac:name="language">unknown</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[unknown code 2]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">sh</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:parameter ac:name="title">A b c</ac:parameter><ac:plain-text-body><![CDATA[no-collapse-title]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">bash</ac:parameter><ac:parameter ac:name="collapse">true</ac:parameter><ac:parameter ac:name="title">A b c</ac:parameter><ac:plain-text-body><![CDATA[collapse-and-title]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">c</ac:parameter><ac:parameter ac:name="collapse">true</ac:parameter><ac:plain-text-body><![CDATA[collapse-no-title]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">nested</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[code
 ``` more code ```
 even more code]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language"></ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[indented code block
diff --git a/pkg/mark/testdata/issue-64-broken-link-droph1.html b/pkg/mark/testdata/issue-64-broken-link-droph1.html
index 0d39ce8..dca9603 100644
--- a/pkg/mark/testdata/issue-64-broken-link-droph1.html
+++ b/pkg/mark/testdata/issue-64-broken-link-droph1.html
@@ -1,1 +1,1 @@
-<p><a href="Page2#Page2-Releasev71-22-Feb-2018(intern)">v71</a></p>
+<a href="Page2#Page2-Releasev71-22-Feb-2018(intern)">v71</a>
diff --git a/pkg/mark/testdata/issue-64-broken-link-stripnewlines.html b/pkg/mark/testdata/issue-64-broken-link-stripnewlines.html
index 0d39ce8..dca9603 100644
--- a/pkg/mark/testdata/issue-64-broken-link-stripnewlines.html
+++ b/pkg/mark/testdata/issue-64-broken-link-stripnewlines.html
@@ -1,1 +1,1 @@
-<p><a href="Page2#Page2-Releasev71-22-Feb-2018(intern)">v71</a></p>
+<a href="Page2#Page2-Releasev71-22-Feb-2018(intern)">v71</a>
diff --git a/pkg/mark/testdata/issue-64-broken-link.html b/pkg/mark/testdata/issue-64-broken-link.html
index 0d39ce8..dca9603 100644
--- a/pkg/mark/testdata/issue-64-broken-link.html
+++ b/pkg/mark/testdata/issue-64-broken-link.html
@@ -1,1 +1,1 @@
-<p><a href="Page2#Page2-Releasev71-22-Feb-2018(intern)">v71</a></p>
+<a href="Page2#Page2-Releasev71-22-Feb-2018(intern)">v71</a>
diff --git a/pkg/mark/testdata/links-droph1.html b/pkg/mark/testdata/links-droph1.html
index 82fd040..b002880 100644
--- a/pkg/mark/testdata/links-droph1.html
+++ b/pkg/mark/testdata/links-droph1.html
@@ -1,17 +1,17 @@
-<p>Use <a href="https://example.com">https://example.com</a></p>
-<p>Use <ac:rich-text-body>aaa</ac:rich-text-body></p>
-<p>Use <ac:link><ri:page ri:content-title="Page"/><ac:plain-text-link-body><![CDATA[page link]]></ac:plain-text-link-body></ac:link></p>
-<p>Use <ac:link><ri:page ri:content-title="AnotherPage"/><ac:plain-text-link-body><![CDATA[AnotherPage]]></ac:plain-text-link-body></ac:link></p>
-<p>Use <ac:link><ri:page ri:content-title="Another Page"/><ac:plain-text-link-body><![CDATA[Another Page]]></ac:plain-text-link-body></ac:link></p>
-<p>Use <ac:link><ri:page ri:content-title="Page With Space"/><ac:plain-text-link-body><![CDATA[page link with spaces]]></ac:plain-text-link-body></ac:link></p>
-<p><ac:image ac:alt="My Image"><ri:attachment ri:filename="test.png"/></ac:image></p>
-<p><ac:image ac:alt="My External Image"><ri:url ri:value="http://confluence.atlassian.com/images/logo/confluence_48_trans.png?key1=value1&amp;key2=value2"/></ac:image></p>
-<p>Use footnotes link <sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup></p>
+Use <a href="https://example.com">https://example.com</a>
+Use <ac:rich-text-body>aaa</ac:rich-text-body>
+Use <ac:link><ri:page ri:content-title="Page"/><ac:plain-text-link-body><![CDATA[page link]]></ac:plain-text-link-body></ac:link>
+Use <ac:link><ri:page ri:content-title="AnotherPage"/><ac:plain-text-link-body><![CDATA[AnotherPage]]></ac:plain-text-link-body></ac:link>
+Use <ac:link><ri:page ri:content-title="Another Page"/><ac:plain-text-link-body><![CDATA[Another Page]]></ac:plain-text-link-body></ac:link>
+Use <ac:link><ri:page ri:content-title="Page With Space"/><ac:plain-text-link-body><![CDATA[page link with spaces]]></ac:plain-text-link-body></ac:link>
+<ac:image ac:alt="My Image"><ri:attachment ri:filename="test.png"/></ac:image>
+<ac:image ac:alt="My External Image"><ri:url ri:value="http://confluence.atlassian.com/images/logo/confluence_48_trans.png?key1=value1&amp;key2=value2"/></ac:image>
+Use footnotes link <sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>
 <div class="footnotes" role="doc-endnotes">
 <hr />
 <ol>
 <li id="fn:1">
-<p>a footnote link&#160;<a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
+a footnote link&#160;<a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a>
 </li>
 </ol>
 </div>
diff --git a/pkg/mark/testdata/links-stripnewlines.html b/pkg/mark/testdata/links-stripnewlines.html
index 82fd040..b002880 100644
--- a/pkg/mark/testdata/links-stripnewlines.html
+++ b/pkg/mark/testdata/links-stripnewlines.html
@@ -1,17 +1,17 @@
-<p>Use <a href="https://example.com">https://example.com</a></p>
-<p>Use <ac:rich-text-body>aaa</ac:rich-text-body></p>
-<p>Use <ac:link><ri:page ri:content-title="Page"/><ac:plain-text-link-body><![CDATA[page link]]></ac:plain-text-link-body></ac:link></p>
-<p>Use <ac:link><ri:page ri:content-title="AnotherPage"/><ac:plain-text-link-body><![CDATA[AnotherPage]]></ac:plain-text-link-body></ac:link></p>
-<p>Use <ac:link><ri:page ri:content-title="Another Page"/><ac:plain-text-link-body><![CDATA[Another Page]]></ac:plain-text-link-body></ac:link></p>
-<p>Use <ac:link><ri:page ri:content-title="Page With Space"/><ac:plain-text-link-body><![CDATA[page link with spaces]]></ac:plain-text-link-body></ac:link></p>
-<p><ac:image ac:alt="My Image"><ri:attachment ri:filename="test.png"/></ac:image></p>
-<p><ac:image ac:alt="My External Image"><ri:url ri:value="http://confluence.atlassian.com/images/logo/confluence_48_trans.png?key1=value1&amp;key2=value2"/></ac:image></p>
-<p>Use footnotes link <sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup></p>
+Use <a href="https://example.com">https://example.com</a>
+Use <ac:rich-text-body>aaa</ac:rich-text-body>
+Use <ac:link><ri:page ri:content-title="Page"/><ac:plain-text-link-body><![CDATA[page link]]></ac:plain-text-link-body></ac:link>
+Use <ac:link><ri:page ri:content-title="AnotherPage"/><ac:plain-text-link-body><![CDATA[AnotherPage]]></ac:plain-text-link-body></ac:link>
+Use <ac:link><ri:page ri:content-title="Another Page"/><ac:plain-text-link-body><![CDATA[Another Page]]></ac:plain-text-link-body></ac:link>
+Use <ac:link><ri:page ri:content-title="Page With Space"/><ac:plain-text-link-body><![CDATA[page link with spaces]]></ac:plain-text-link-body></ac:link>
+<ac:image ac:alt="My Image"><ri:attachment ri:filename="test.png"/></ac:image>
+<ac:image ac:alt="My External Image"><ri:url ri:value="http://confluence.atlassian.com/images/logo/confluence_48_trans.png?key1=value1&amp;key2=value2"/></ac:image>
+Use footnotes link <sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>
 <div class="footnotes" role="doc-endnotes">
 <hr />
 <ol>
 <li id="fn:1">
-<p>a footnote link&#160;<a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
+a footnote link&#160;<a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a>
 </li>
 </ol>
 </div>
diff --git a/pkg/mark/testdata/links.html b/pkg/mark/testdata/links.html
index 82fd040..b002880 100644
--- a/pkg/mark/testdata/links.html
+++ b/pkg/mark/testdata/links.html
@@ -1,17 +1,17 @@
-<p>Use <a href="https://example.com">https://example.com</a></p>
-<p>Use <ac:rich-text-body>aaa</ac:rich-text-body></p>
-<p>Use <ac:link><ri:page ri:content-title="Page"/><ac:plain-text-link-body><![CDATA[page link]]></ac:plain-text-link-body></ac:link></p>
-<p>Use <ac:link><ri:page ri:content-title="AnotherPage"/><ac:plain-text-link-body><![CDATA[AnotherPage]]></ac:plain-text-link-body></ac:link></p>
-<p>Use <ac:link><ri:page ri:content-title="Another Page"/><ac:plain-text-link-body><![CDATA[Another Page]]></ac:plain-text-link-body></ac:link></p>
-<p>Use <ac:link><ri:page ri:content-title="Page With Space"/><ac:plain-text-link-body><![CDATA[page link with spaces]]></ac:plain-text-link-body></ac:link></p>
-<p><ac:image ac:alt="My Image"><ri:attachment ri:filename="test.png"/></ac:image></p>
-<p><ac:image ac:alt="My External Image"><ri:url ri:value="http://confluence.atlassian.com/images/logo/confluence_48_trans.png?key1=value1&amp;key2=value2"/></ac:image></p>
-<p>Use footnotes link <sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup></p>
+Use <a href="https://example.com">https://example.com</a>
+Use <ac:rich-text-body>aaa</ac:rich-text-body>
+Use <ac:link><ri:page ri:content-title="Page"/><ac:plain-text-link-body><![CDATA[page link]]></ac:plain-text-link-body></ac:link>
+Use <ac:link><ri:page ri:content-title="AnotherPage"/><ac:plain-text-link-body><![CDATA[AnotherPage]]></ac:plain-text-link-body></ac:link>
+Use <ac:link><ri:page ri:content-title="Another Page"/><ac:plain-text-link-body><![CDATA[Another Page]]></ac:plain-text-link-body></ac:link>
+Use <ac:link><ri:page ri:content-title="Page With Space"/><ac:plain-text-link-body><![CDATA[page link with spaces]]></ac:plain-text-link-body></ac:link>
+<ac:image ac:alt="My Image"><ri:attachment ri:filename="test.png"/></ac:image>
+<ac:image ac:alt="My External Image"><ri:url ri:value="http://confluence.atlassian.com/images/logo/confluence_48_trans.png?key1=value1&amp;key2=value2"/></ac:image>
+Use footnotes link <sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>
 <div class="footnotes" role="doc-endnotes">
 <hr />
 <ol>
 <li id="fn:1">
-<p>a footnote link&#160;<a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
+a footnote link&#160;<a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a>
 </li>
 </ol>
 </div>
diff --git a/pkg/mark/testdata/lists-droph1.html b/pkg/mark/testdata/lists-droph1.html
index af27c54..11aa2ca 100644
--- a/pkg/mark/testdata/lists-droph1.html
+++ b/pkg/mark/testdata/lists-droph1.html
@@ -13,7 +13,7 @@
 </ul>
 </li>
 </ul>
-<p>text</p>
+text
 <ul>
 <li>a</li>
 <li>b</li>
diff --git a/pkg/mark/testdata/lists-stripnewlines.html b/pkg/mark/testdata/lists-stripnewlines.html
index af27c54..11aa2ca 100644
--- a/pkg/mark/testdata/lists-stripnewlines.html
+++ b/pkg/mark/testdata/lists-stripnewlines.html
@@ -13,7 +13,7 @@
 </ul>
 </li>
 </ul>
-<p>text</p>
+text
 <ul>
 <li>a</li>
 <li>b</li>
diff --git a/pkg/mark/testdata/lists.html b/pkg/mark/testdata/lists.html
index af27c54..11aa2ca 100644
--- a/pkg/mark/testdata/lists.html
+++ b/pkg/mark/testdata/lists.html
@@ -13,7 +13,7 @@
 </ul>
 </li>
 </ul>
-<p>text</p>
+text
 <ul>
 <li>a</li>
 <li>b</li>
diff --git a/pkg/mark/testdata/macro-include-droph1.html b/pkg/mark/testdata/macro-include-droph1.html
index 8d8ba05..ccf5127 100644
--- a/pkg/mark/testdata/macro-include-droph1.html
+++ b/pkg/mark/testdata/macro-include-droph1.html
@@ -1,6 +1,26 @@
-<p><foo>bar</foo></p>
-<p><ac:structured-macro ac:name="info">
+<foo>bar</foo>
+<ac:structured-macro ac:name="info">
 <ac:parameter ac:name="icon">true</ac:parameter>
 <ac:parameter ac:name="title">Attention</ac:parameter>
 <ac:rich-text-body>This is an info!</ac:rich-text-body>
-</ac:structured-macro></p>
+</ac:structured-macro>
+<ac:structured-macro ac:name="info">
+<ac:parameter ac:name="icon">true</ac:parameter>
+<ac:parameter ac:name="title">Attention</ac:parameter>
+<ac:rich-text-body>
+<table>
+<thead>
+<tr>
+<th>Header 1</th>
+<th>Header 2</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td>Cell A</td>
+<td>Cell B</td>
+</tr>
+</tbody>
+</table>
+</ac:rich-text-body>
+</ac:structured-macro>
diff --git a/pkg/mark/testdata/macro-include-stripnewlines.html b/pkg/mark/testdata/macro-include-stripnewlines.html
index 52e4af7..5ad6298 100644
--- a/pkg/mark/testdata/macro-include-stripnewlines.html
+++ b/pkg/mark/testdata/macro-include-stripnewlines.html
@@ -1,2 +1,18 @@
-<p><foo>bar</foo></p>
-<p><ac:structured-macro ac:name="info"> <ac:parameter ac:name="icon">true</ac:parameter> <ac:parameter ac:name="title">Attention</ac:parameter> <ac:rich-text-body>This is an info!</ac:rich-text-body> </ac:structured-macro></p>
+<foo>bar</foo>
+<ac:structured-macro ac:name="info"> <ac:parameter ac:name="icon">true</ac:parameter> <ac:parameter ac:name="title">Attention</ac:parameter> <ac:rich-text-body>This is an info!</ac:rich-text-body> </ac:structured-macro>
+<ac:structured-macro ac:name="info"> <ac:parameter ac:name="icon">true</ac:parameter> <ac:parameter ac:name="title">Attention</ac:parameter> <ac:rich-text-body>
+<table>
+<thead>
+<tr>
+<th>Header 1</th>
+<th>Header 2</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td>Cell A</td>
+<td>Cell B</td>
+</tr>
+</tbody>
+</table>
+</ac:rich-text-body> </ac:structured-macro>
diff --git a/pkg/mark/testdata/macro-include.html b/pkg/mark/testdata/macro-include.html
index 8d8ba05..ccf5127 100644
--- a/pkg/mark/testdata/macro-include.html
+++ b/pkg/mark/testdata/macro-include.html
@@ -1,6 +1,26 @@
-<p><foo>bar</foo></p>
-<p><ac:structured-macro ac:name="info">
+<foo>bar</foo>
+<ac:structured-macro ac:name="info">
 <ac:parameter ac:name="icon">true</ac:parameter>
 <ac:parameter ac:name="title">Attention</ac:parameter>
 <ac:rich-text-body>This is an info!</ac:rich-text-body>
-</ac:structured-macro></p>
+</ac:structured-macro>
+<ac:structured-macro ac:name="info">
+<ac:parameter ac:name="icon">true</ac:parameter>
+<ac:parameter ac:name="title">Attention</ac:parameter>
+<ac:rich-text-body>
+<table>
+<thead>
+<tr>
+<th>Header 1</th>
+<th>Header 2</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td>Cell A</td>
+<td>Cell B</td>
+</tr>
+</tbody>
+</table>
+</ac:rich-text-body>
+</ac:structured-macro>
diff --git a/pkg/mark/testdata/macro-include.md b/pkg/mark/testdata/macro-include.md
index c8d3d89..84123d1 100644
--- a/pkg/mark/testdata/macro-include.md
+++ b/pkg/mark/testdata/macro-include.md
@@ -4,4 +4,15 @@
 <ac:parameter ac:name="icon">true</ac:parameter>
 <ac:parameter ac:name="title">Attention</ac:parameter>
 <ac:rich-text-body>This is an info!</ac:rich-text-body>
-</ac:structured-macro>
\ No newline at end of file
+</ac:structured-macro>
+
+<ac:structured-macro ac:name="info">
+<ac:parameter ac:name="icon">true</ac:parameter>
+<ac:parameter ac:name="title">Attention</ac:parameter>
+<ac:rich-text-body>
+| Header 1 | Header 2 |
+|---|---|
+| Cell A | Cell B |
+
+</ac:rich-text-body>
+</ac:structured-macro>
diff --git a/pkg/mark/testdata/newlines-droph1.html b/pkg/mark/testdata/newlines-droph1.html
index b97e510..272fe20 100644
--- a/pkg/mark/testdata/newlines-droph1.html
+++ b/pkg/mark/testdata/newlines-droph1.html
@@ -1,10 +1,10 @@
-<p>one-1
-one-2</p>
-<p>two-1</p>
-<p>two-2</p>
-<p>three-1</p>
-<p>three-2</p>
-<p>space-1
-space-2</p>
-<p>2space-1<br />
-2space-2</p>
+one-1
+one-2
+two-1
+two-2
+three-1
+three-2
+space-1
+space-2
+2space-1<br />
+2space-2
diff --git a/pkg/mark/testdata/newlines-stripnewlines.html b/pkg/mark/testdata/newlines-stripnewlines.html
index 2fd4dc0..cca4996 100644
--- a/pkg/mark/testdata/newlines-stripnewlines.html
+++ b/pkg/mark/testdata/newlines-stripnewlines.html
@@ -1,8 +1,8 @@
-<p>one-1 one-2</p>
-<p>two-1</p>
-<p>two-2</p>
-<p>three-1</p>
-<p>three-2</p>
-<p>space-1 space-2</p>
-<p>2space-1<br />
-2space-2</p>
+one-1 one-2
+two-1
+two-2
+three-1
+three-2
+space-1 space-2
+2space-1<br />
+2space-2
diff --git a/pkg/mark/testdata/newlines.html b/pkg/mark/testdata/newlines.html
index b97e510..272fe20 100644
--- a/pkg/mark/testdata/newlines.html
+++ b/pkg/mark/testdata/newlines.html
@@ -1,10 +1,10 @@
-<p>one-1
-one-2</p>
-<p>two-1</p>
-<p>two-2</p>
-<p>three-1</p>
-<p>three-2</p>
-<p>space-1
-space-2</p>
-<p>2space-1<br />
-2space-2</p>
+one-1
+one-2
+two-1
+two-2
+three-1
+three-2
+space-1
+space-2
+2space-1<br />
+2space-2
diff --git a/pkg/mark/testdata/pagelayout-droph1.html b/pkg/mark/testdata/pagelayout-droph1.html
index a244202..23f17d5 100644
--- a/pkg/mark/testdata/pagelayout-droph1.html
+++ b/pkg/mark/testdata/pagelayout-droph1.html
@@ -1,18 +1,18 @@
 <ac:layout>
 <ac:layout-section ac:type="three_with_sidebars">
 <ac:layout-cell>
-<p>More Content</p>
+More Content
 </ac:layout-cell>
 <ac:layout-cell>
-<p>More Content</p>
+More Content
 </ac:layout-cell>
 <ac:layout-cell>
-<p>Even More Content</p>
+Even More Content
 </ac:layout-cell>
 </ac:layout-section>
 <ac:layout-section ac:type="single">
 <ac:layout-cell>
-<p>Still More Content</p>
+Still More Content
 </ac:layout-cell>
 </ac:layout-section>
 </ac:layout>
diff --git a/pkg/mark/testdata/pagelayout-stripnewlines.html b/pkg/mark/testdata/pagelayout-stripnewlines.html
index a244202..23f17d5 100644
--- a/pkg/mark/testdata/pagelayout-stripnewlines.html
+++ b/pkg/mark/testdata/pagelayout-stripnewlines.html
@@ -1,18 +1,18 @@
 <ac:layout>
 <ac:layout-section ac:type="three_with_sidebars">
 <ac:layout-cell>
-<p>More Content</p>
+More Content
 </ac:layout-cell>
 <ac:layout-cell>
-<p>More Content</p>
+More Content
 </ac:layout-cell>
 <ac:layout-cell>
-<p>Even More Content</p>
+Even More Content
 </ac:layout-cell>
 </ac:layout-section>
 <ac:layout-section ac:type="single">
 <ac:layout-cell>
-<p>Still More Content</p>
+Still More Content
 </ac:layout-cell>
 </ac:layout-section>
 </ac:layout>
diff --git a/pkg/mark/testdata/pagelayout.html b/pkg/mark/testdata/pagelayout.html
index a244202..23f17d5 100644
--- a/pkg/mark/testdata/pagelayout.html
+++ b/pkg/mark/testdata/pagelayout.html
@@ -1,18 +1,18 @@
 <ac:layout>
 <ac:layout-section ac:type="three_with_sidebars">
 <ac:layout-cell>
-<p>More Content</p>
+More Content
 </ac:layout-cell>
 <ac:layout-cell>
-<p>More Content</p>
+More Content
 </ac:layout-cell>
 <ac:layout-cell>
-<p>Even More Content</p>
+Even More Content
 </ac:layout-cell>
 </ac:layout-section>
 <ac:layout-section ac:type="single">
 <ac:layout-cell>
-<p>Still More Content</p>
+Still More Content
 </ac:layout-cell>
 </ac:layout-section>
 </ac:layout>
diff --git a/pkg/mark/testdata/quotes-droph1.html b/pkg/mark/testdata/quotes-droph1.html
index d8fdcdf..e90782a 100644
--- a/pkg/mark/testdata/quotes-droph1.html
+++ b/pkg/mark/testdata/quotes-droph1.html
@@ -1,19 +1,19 @@
 <h2 id="first-heading">First Heading</h2>
 <ac:structured-macro ac:name="note"><ac:parameter ac:name="icon">true</ac:parameter><ac:rich-text-body>
-<p><strong>NOTES:</strong></p>
+<strong>NOTES:</strong>
 <ol>
 <li>Note number one</li>
 <li>Note number two</li>
 </ol>
 <blockquote>
-<p>a
-b</p>
+a
+b
 </blockquote>
-<p><strong>Warn (Should not be picked as blockquote type)</strong></p>
+<strong>Warn (Should not be picked as blockquote type)</strong>
 </ac:rich-text-body></ac:structured-macro>
 <h2 id="second-heading">Second Heading</h2>
 <ac:structured-macro ac:name="warn"><ac:parameter ac:name="icon">true</ac:parameter><ac:rich-text-body>
-<p><strong>Warn</strong></p>
+<strong>Warn</strong>
 <ul>
 <li>Warn bullet 1</li>
 <li>Warn bullet 2</li>
@@ -26,9 +26,9 @@ that runs long</li>
 <h2 id="third-heading">Third Heading</h2>
 <ac:structured-macro ac:name="info"><ac:parameter ac:name="icon">true</ac:parameter><ac:rich-text-body>
 <!-- Info -->
-<p>Test</p>
+Test
 </ac:rich-text-body></ac:structured-macro>
 <h2 id="simple-blockquote">Simple Blockquote</h2>
 <blockquote>
-<p>This paragraph is a simple blockquote</p>
+This paragraph is a simple blockquote
 </blockquote>
diff --git a/pkg/mark/testdata/quotes-stripnewlines.html b/pkg/mark/testdata/quotes-stripnewlines.html
index 7a43019..d0520a9 100644
--- a/pkg/mark/testdata/quotes-stripnewlines.html
+++ b/pkg/mark/testdata/quotes-stripnewlines.html
@@ -1,19 +1,19 @@
 <h1 id="main-heading">Main Heading</h1>
 <h2 id="first-heading">First Heading</h2>
 <ac:structured-macro ac:name="note"><ac:parameter ac:name="icon">true</ac:parameter><ac:rich-text-body>
-<p><strong>NOTES:</strong></p>
+<strong>NOTES:</strong>
 <ol>
 <li>Note number one</li>
 <li>Note number two</li>
 </ol>
 <blockquote>
-<p>a b</p>
+a b
 </blockquote>
-<p><strong>Warn (Should not be picked as blockquote type)</strong></p>
+<strong>Warn (Should not be picked as blockquote type)</strong>
 </ac:rich-text-body></ac:structured-macro>
 <h2 id="second-heading">Second Heading</h2>
 <ac:structured-macro ac:name="warn"><ac:parameter ac:name="icon">true</ac:parameter><ac:rich-text-body>
-<p><strong>Warn</strong></p>
+<strong>Warn</strong>
 <ul>
 <li>Warn bullet 1</li>
 <li>Warn bullet 2</li>
@@ -25,9 +25,9 @@
 <h2 id="third-heading">Third Heading</h2>
 <ac:structured-macro ac:name="info"><ac:parameter ac:name="icon">true</ac:parameter><ac:rich-text-body>
 <!-- Info -->
-<p>Test</p>
+Test
 </ac:rich-text-body></ac:structured-macro>
 <h2 id="simple-blockquote">Simple Blockquote</h2>
 <blockquote>
-<p>This paragraph is a simple blockquote</p>
+This paragraph is a simple blockquote
 </blockquote>
diff --git a/pkg/mark/testdata/quotes.html b/pkg/mark/testdata/quotes.html
index c1519c7..957e7eb 100644
--- a/pkg/mark/testdata/quotes.html
+++ b/pkg/mark/testdata/quotes.html
@@ -1,20 +1,20 @@
 <h1 id="main-heading">Main Heading</h1>
 <h2 id="first-heading">First Heading</h2>
 <ac:structured-macro ac:name="note"><ac:parameter ac:name="icon">true</ac:parameter><ac:rich-text-body>
-<p><strong>NOTES:</strong></p>
+<strong>NOTES:</strong>
 <ol>
 <li>Note number one</li>
 <li>Note number two</li>
 </ol>
 <blockquote>
-<p>a
-b</p>
+a
+b
 </blockquote>
-<p><strong>Warn (Should not be picked as blockquote type)</strong></p>
+<strong>Warn (Should not be picked as blockquote type)</strong>
 </ac:rich-text-body></ac:structured-macro>
 <h2 id="second-heading">Second Heading</h2>
 <ac:structured-macro ac:name="warn"><ac:parameter ac:name="icon">true</ac:parameter><ac:rich-text-body>
-<p><strong>Warn</strong></p>
+<strong>Warn</strong>
 <ul>
 <li>Warn bullet 1</li>
 <li>Warn bullet 2</li>
@@ -27,9 +27,9 @@ that runs long</li>
 <h2 id="third-heading">Third Heading</h2>
 <ac:structured-macro ac:name="info"><ac:parameter ac:name="icon">true</ac:parameter><ac:rich-text-body>
 <!-- Info -->
-<p>Test</p>
+Test
 </ac:rich-text-body></ac:structured-macro>
 <h2 id="simple-blockquote">Simple Blockquote</h2>
 <blockquote>
-<p>This paragraph is a simple blockquote</p>
+This paragraph is a simple blockquote
 </blockquote>
diff --git a/pkg/mark/testdata/tags-droph1.html b/pkg/mark/testdata/tags-droph1.html
index a5161db..5c3f317 100644
--- a/pkg/mark/testdata/tags-droph1.html
+++ b/pkg/mark/testdata/tags-droph1.html
@@ -1,6 +1,6 @@
-<p><b>bold</b>
-<strong>bold</strong></p>
-<p><i>vitalik</i>
-<em>vitalik</em></p>
-<p>
strikethrough

-<del>strikethrough</del></p>
+<b>bold</b>
+<strong>bold</strong>
+<i>vitalik</i>
+<em>vitalik</em>
+
strikethrough

+<del>strikethrough</del>
diff --git a/pkg/mark/testdata/tags-stripnewlines.html b/pkg/mark/testdata/tags-stripnewlines.html
index cc0698b..85c1878 100644
--- a/pkg/mark/testdata/tags-stripnewlines.html
+++ b/pkg/mark/testdata/tags-stripnewlines.html
@@ -1,3 +1,3 @@
-<p><b>bold</b> <strong>bold</strong></p>
-<p><i>vitalik</i> <em>vitalik</em></p>
-<p>
strikethrough
 <del>strikethrough</del></p>
+<b>bold</b> <strong>bold</strong>
+<i>vitalik</i> <em>vitalik</em>
+
strikethrough
 <del>strikethrough</del>
diff --git a/pkg/mark/testdata/tags.html b/pkg/mark/testdata/tags.html
index a5161db..5c3f317 100644
--- a/pkg/mark/testdata/tags.html
+++ b/pkg/mark/testdata/tags.html
@@ -1,6 +1,6 @@
-<p><b>bold</b>
-<strong>bold</strong></p>
-<p><i>vitalik</i>
-<em>vitalik</em></p>
-<p>
strikethrough

-<del>strikethrough</del></p>
+<b>bold</b>
+<strong>bold</strong>
+<i>vitalik</i>
+<em>vitalik</em>
+
strikethrough

+<del>strikethrough</del>