From eb39e035f02e0a78db86f7baf6c96f961c1824b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Mon, 12 Aug 2024 14:14:25 +0200 Subject: [PATCH] Fix paragraphs --- pkg/mark/renderer/paragraph.go | 15 +++++++++- pkg/mark/testdata/codes-droph1.html | 6 ++-- pkg/mark/testdata/codes-stripnewlines.html | 4 +-- pkg/mark/testdata/codes.html | 6 ++-- .../testdata/issue-64-broken-link-droph1.html | 2 +- .../issue-64-broken-link-stripnewlines.html | 2 +- pkg/mark/testdata/issue-64-broken-link.html | 2 +- pkg/mark/testdata/links-droph1.html | 28 +++++++++---------- pkg/mark/testdata/links-stripnewlines.html | 28 +++++++++---------- pkg/mark/testdata/links.html | 28 +++++++++---------- pkg/mark/testdata/lists-droph1.html | 2 +- pkg/mark/testdata/lists-stripnewlines.html | 2 +- pkg/mark/testdata/lists.html | 2 +- pkg/mark/testdata/newlines-droph1.html | 20 ++++++------- pkg/mark/testdata/newlines-stripnewlines.html | 16 +++++------ pkg/mark/testdata/newlines.html | 20 ++++++------- pkg/mark/testdata/pagelayout-droph1.html | 8 +++--- .../testdata/pagelayout-stripnewlines.html | 8 +++--- pkg/mark/testdata/pagelayout.html | 8 +++--- pkg/mark/testdata/quotes-droph1.html | 14 +++++----- pkg/mark/testdata/quotes-stripnewlines.html | 12 ++++---- pkg/mark/testdata/quotes.html | 14 +++++----- pkg/mark/testdata/tags-droph1.html | 6 ++-- pkg/mark/testdata/tags-stripnewlines.html | 9 ++++-- pkg/mark/testdata/tags.html | 6 ++-- pkg/mark/testdata/tags.md | 3 ++ 26 files changed, 145 insertions(+), 126 deletions(-) diff --git a/pkg/mark/renderer/paragraph.go b/pkg/mark/renderer/paragraph.go index df9bc49..49c69a1 100644 --- a/pkg/mark/renderer/paragraph.go +++ b/pkg/mark/renderer/paragraph.go @@ -24,7 +24,20 @@ func (r *ConfluenceParagraphRenderer) RegisterFuncs(reg renderer.NodeRendererFun } func (r *ConfluenceParagraphRenderer) renderParagraph(w util.BufWriter, source []byte, n ast.Node, entering bool) (ast.WalkStatus, error) { - if !entering { + if entering { + if n.FirstChild().Kind() != ast.KindRawHTML { + if n.Attributes() != nil { + _, _ = w.WriteString("') + } else { + _, _ = w.WriteString("

") + } + } + } else { + if n.FirstChild().Kind() != ast.KindRawHTML { + _, _ = w.WriteString("

") + } _, _ = w.WriteString("\n") } return ast.WalkContinue, nil diff --git a/pkg/mark/testdata/codes-droph1.html b/pkg/mark/testdata/codes-droph1.html index bcf5be7..733410b 100644 --- a/pkg/mark/testdata/codes-droph1.html +++ b/pkg/mark/testdata/codes-droph1.html @@ -1,7 +1,7 @@ -inline +

inline

falsebashfalsebashfalseunknownfalsetext -text 2 +]]>unknownfalse

text +text 2

unknownfalseshfalseA b cbashtrueA b cctruenestedfalsefalseinline +

inline

falsebashfalsebashfalseunknownfalsetext text 2 +]]>
unknownfalse

text text 2

unknownfalseshfalseA b cbashtrueA b cctruenestedfalsefalseinline +

inline

falsebashfalsebashfalseunknownfalsetext -text 2 +]]>
unknownfalse

text +text 2

unknownfalseshfalseA b cbashtrueA b cctruenestedfalsefalsev71 +

v71

diff --git a/pkg/mark/testdata/issue-64-broken-link-stripnewlines.html b/pkg/mark/testdata/issue-64-broken-link-stripnewlines.html index dca9603..0d39ce8 100644 --- a/pkg/mark/testdata/issue-64-broken-link-stripnewlines.html +++ b/pkg/mark/testdata/issue-64-broken-link-stripnewlines.html @@ -1 +1 @@ -v71 +

v71

diff --git a/pkg/mark/testdata/issue-64-broken-link.html b/pkg/mark/testdata/issue-64-broken-link.html index dca9603..0d39ce8 100644 --- a/pkg/mark/testdata/issue-64-broken-link.html +++ b/pkg/mark/testdata/issue-64-broken-link.html @@ -1 +1 @@ -v71 +

v71

diff --git a/pkg/mark/testdata/links-droph1.html b/pkg/mark/testdata/links-droph1.html index 6160135..d9ca603 100644 --- a/pkg/mark/testdata/links-droph1.html +++ b/pkg/mark/testdata/links-droph1.html @@ -1,21 +1,21 @@ -Use https://example.com -Use aaa -Use -Use -Use -Use -Use - - - - -Use footnotes link 1 -Use Link [Text] +

Use https://example.com

+

Use aaa

+

Use

+

Use

+

Use

+

Use

+

Use

+

+

+

+

+

Use footnotes link 1

+

Use Link [Text]


  1. -a footnote link ↩︎ +

    a footnote link ↩︎

diff --git a/pkg/mark/testdata/links-stripnewlines.html b/pkg/mark/testdata/links-stripnewlines.html index 6160135..d9ca603 100644 --- a/pkg/mark/testdata/links-stripnewlines.html +++ b/pkg/mark/testdata/links-stripnewlines.html @@ -1,21 +1,21 @@ -Use https://example.com -Use aaa -Use -Use -Use -Use -Use - - - - -Use footnotes link 1 -Use Link [Text] +

Use https://example.com

+

Use aaa

+

Use

+

Use

+

Use

+

Use

+

Use

+

+

+

+

+

Use footnotes link 1

+

Use Link [Text]


  1. -a footnote link ↩︎ +

    a footnote link ↩︎

diff --git a/pkg/mark/testdata/links.html b/pkg/mark/testdata/links.html index 6160135..d9ca603 100644 --- a/pkg/mark/testdata/links.html +++ b/pkg/mark/testdata/links.html @@ -1,21 +1,21 @@ -Use https://example.com -Use aaa -Use -Use -Use -Use -Use - - - - -Use footnotes link 1 -Use Link [Text] +

Use https://example.com

+

Use aaa

+

Use

+

Use

+

Use

+

Use

+

Use

+

+

+

+

+

Use footnotes link 1

+

Use Link [Text]


  1. -a footnote link ↩︎ +

    a footnote link ↩︎

diff --git a/pkg/mark/testdata/lists-droph1.html b/pkg/mark/testdata/lists-droph1.html index 11aa2ca..af27c54 100644 --- a/pkg/mark/testdata/lists-droph1.html +++ b/pkg/mark/testdata/lists-droph1.html @@ -13,7 +13,7 @@ -text +

text

  • a
  • b
  • diff --git a/pkg/mark/testdata/lists-stripnewlines.html b/pkg/mark/testdata/lists-stripnewlines.html index 11aa2ca..af27c54 100644 --- a/pkg/mark/testdata/lists-stripnewlines.html +++ b/pkg/mark/testdata/lists-stripnewlines.html @@ -13,7 +13,7 @@
-text +

text

  • a
  • b
  • diff --git a/pkg/mark/testdata/lists.html b/pkg/mark/testdata/lists.html index 11aa2ca..af27c54 100644 --- a/pkg/mark/testdata/lists.html +++ b/pkg/mark/testdata/lists.html @@ -13,7 +13,7 @@
-text +

text

  • a
  • b
  • diff --git a/pkg/mark/testdata/newlines-droph1.html b/pkg/mark/testdata/newlines-droph1.html index 272fe20..b97e510 100644 --- a/pkg/mark/testdata/newlines-droph1.html +++ b/pkg/mark/testdata/newlines-droph1.html @@ -1,10 +1,10 @@ -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

    diff --git a/pkg/mark/testdata/newlines-stripnewlines.html b/pkg/mark/testdata/newlines-stripnewlines.html index cca4996..2fd4dc0 100644 --- a/pkg/mark/testdata/newlines-stripnewlines.html +++ b/pkg/mark/testdata/newlines-stripnewlines.html @@ -1,8 +1,8 @@ -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

    diff --git a/pkg/mark/testdata/newlines.html b/pkg/mark/testdata/newlines.html index 272fe20..b97e510 100644 --- a/pkg/mark/testdata/newlines.html +++ b/pkg/mark/testdata/newlines.html @@ -1,10 +1,10 @@ -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

    diff --git a/pkg/mark/testdata/pagelayout-droph1.html b/pkg/mark/testdata/pagelayout-droph1.html index 23f17d5..a244202 100644 --- a/pkg/mark/testdata/pagelayout-droph1.html +++ b/pkg/mark/testdata/pagelayout-droph1.html @@ -1,18 +1,18 @@ -More Content +

    More Content

    -More Content +

    More Content

    -Even More Content +

    Even More Content

    -Still More Content +

    Still More Content

    diff --git a/pkg/mark/testdata/pagelayout-stripnewlines.html b/pkg/mark/testdata/pagelayout-stripnewlines.html index 23f17d5..a244202 100644 --- a/pkg/mark/testdata/pagelayout-stripnewlines.html +++ b/pkg/mark/testdata/pagelayout-stripnewlines.html @@ -1,18 +1,18 @@ -More Content +

    More Content

    -More Content +

    More Content

    -Even More Content +

    Even More Content

    -Still More Content +

    Still More Content

    diff --git a/pkg/mark/testdata/pagelayout.html b/pkg/mark/testdata/pagelayout.html index 23f17d5..a244202 100644 --- a/pkg/mark/testdata/pagelayout.html +++ b/pkg/mark/testdata/pagelayout.html @@ -1,18 +1,18 @@ -More Content +

    More Content

    -More Content +

    More Content

    -Even More Content +

    Even More Content

    -Still More Content +

    Still More Content

    diff --git a/pkg/mark/testdata/quotes-droph1.html b/pkg/mark/testdata/quotes-droph1.html index e90782a..d8fdcdf 100644 --- a/pkg/mark/testdata/quotes-droph1.html +++ b/pkg/mark/testdata/quotes-droph1.html @@ -1,19 +1,19 @@

    First Heading

    true -NOTES: +

    NOTES:

    1. Note number one
    2. Note number two
    -a -b +

    a +b

    -Warn (Should not be picked as blockquote type) +

    Warn (Should not be picked as blockquote type)

    Second Heading

    true -Warn +

    Warn

    • Warn bullet 1
    • Warn bullet 2
    • @@ -26,9 +26,9 @@ that runs long

      Third Heading

      true -Test +

      Test

      Simple Blockquote

      -This paragraph is a simple blockquote +

      This paragraph is a simple blockquote

      diff --git a/pkg/mark/testdata/quotes-stripnewlines.html b/pkg/mark/testdata/quotes-stripnewlines.html index d0520a9..7a43019 100644 --- a/pkg/mark/testdata/quotes-stripnewlines.html +++ b/pkg/mark/testdata/quotes-stripnewlines.html @@ -1,19 +1,19 @@

      Main Heading

      First Heading

      true -NOTES: +

      NOTES:

      1. Note number one
      2. Note number two
      -a b +

      a b

      -Warn (Should not be picked as blockquote type) +

      Warn (Should not be picked as blockquote type)

      Second Heading

      true -Warn +

      Warn

      • Warn bullet 1
      • Warn bullet 2
      • @@ -25,9 +25,9 @@ a b

        Third Heading

        true -Test +

        Test

        Simple Blockquote

        -This paragraph is a simple blockquote +

        This paragraph is a simple blockquote

        diff --git a/pkg/mark/testdata/quotes.html b/pkg/mark/testdata/quotes.html index 957e7eb..c1519c7 100644 --- a/pkg/mark/testdata/quotes.html +++ b/pkg/mark/testdata/quotes.html @@ -1,20 +1,20 @@

        Main Heading

        First Heading

        true -NOTES: +

        NOTES:

        1. Note number one
        2. Note number two
        -a -b +

        a +b

        -Warn (Should not be picked as blockquote type) +

        Warn (Should not be picked as blockquote type)

        Second Heading

        true -Warn +

        Warn

        • Warn bullet 1
        • Warn bullet 2
        • @@ -27,9 +27,9 @@ that runs long

          Third Heading

          true -Test +

          Test

          Simple Blockquote

          -This paragraph is a simple blockquote +

          This paragraph is a simple blockquote

          diff --git a/pkg/mark/testdata/tags-droph1.html b/pkg/mark/testdata/tags-droph1.html index 5c3f317..7fd51c0 100644 --- a/pkg/mark/testdata/tags-droph1.html +++ b/pkg/mark/testdata/tags-droph1.html @@ -1,6 +1,6 @@ bold -bold +

          bold

          vitalik -vitalik +

          vitalik

          strikethrough -strikethrough +

          strikethrough

          diff --git a/pkg/mark/testdata/tags-stripnewlines.html b/pkg/mark/testdata/tags-stripnewlines.html index 85c1878..7fd51c0 100644 --- a/pkg/mark/testdata/tags-stripnewlines.html +++ b/pkg/mark/testdata/tags-stripnewlines.html @@ -1,3 +1,6 @@ -bold bold -vitalik vitalik -strikethrough strikethrough +bold +

          bold

          +vitalik +

          vitalik

          +strikethrough +

          strikethrough

          diff --git a/pkg/mark/testdata/tags.html b/pkg/mark/testdata/tags.html index 5c3f317..7fd51c0 100644 --- a/pkg/mark/testdata/tags.html +++ b/pkg/mark/testdata/tags.html @@ -1,6 +1,6 @@ bold -bold +

          bold

          vitalik -vitalik +

          vitalik

          strikethrough -strikethrough +

          strikethrough

          diff --git a/pkg/mark/testdata/tags.md b/pkg/mark/testdata/tags.md index 502c6d6..1d247d6 100644 --- a/pkg/mark/testdata/tags.md +++ b/pkg/mark/testdata/tags.md @@ -1,8 +1,11 @@ bold + **bold** vitalik + *vitalik* strikethrough + ~~strikethrough~~