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 +} 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 @@ -
inline
inline
text -text 2
+]]>inline
+inline
text text 2
+]]>inline
+inline
text -text 2
+]]>Use
Use
Use
Use
Use
Use footnotes link 1
+Use https://example.com +UseUse
Use
Use
Use
Use
Use footnotes link 1
+Use https://example.com +UseUse
Use
Use
Use
Use
Use footnotes link 1
+Use https://example.com +Usetext
+texttext
+texttext
+textHeader 1 | +Header 2 | +
---|---|
Cell A | +Cell B | +
Header 1 | +Header 2 | +
---|---|
Cell A | +Cell B | +
Header 1 | +Header 2 | +
---|---|
Cell A | +Cell B | +
one-1 -one-2
-two-1
-two-2
-three-1
-three-2
-space-1 -space-2
-2space-1
-2space-2
one-1 one-2
-two-1
-two-2
-three-1
-three-2
-space-1 space-2
-2space-1
-2space-2
one-1 -one-2
-two-1
-two-2
-three-1
-three-2
-space-1 -space-2
-2space-1
-2space-2
More Content
+More ContentMore Content
+More ContentEven More Content
+Even More ContentStill More Content
+Still More ContentMore Content
+More ContentMore Content
+More ContentEven More Content
+Even More ContentStill More Content
+Still More ContentMore Content
+More ContentMore Content
+More ContentEven More Content
+Even More ContentStill More Content
+Still More ContentNOTES:
+NOTES:--a -b
+a +b
Warn (Should not be picked as blockquote type)
+Warn (Should not be picked as blockquote type)Warn
+WarnTest
+Test-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 @@This paragraph is a simple blockquote
+This paragraph is a simple blockquote
NOTES:
+NOTES:--a b
+a b
Warn (Should not be picked as blockquote type)
+Warn (Should not be picked as blockquote type)Warn
+WarnTest
+Test-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 @@This paragraph is a simple blockquote
+This paragraph is a simple blockquote
NOTES:
+NOTES:--a -b
+a +b
Warn (Should not be picked as blockquote type)
+Warn (Should not be picked as blockquote type)Warn
+WarnTest
+Test-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 @@ -This paragraph is a simple blockquote
+This paragraph is a simple blockquote
bold -bold
-vitalik -vitalik
-strikethrough
-strikethrough
bold bold
-vitalik vitalik
-strikethrough strikethrough
bold -bold
-vitalik -vitalik
-strikethrough
-strikethrough