Fix custom link renderer and add tests for Confluence links

Since we now have a custom parser for <ac:*/> tags, the custom link
renderer added an additional </a> tag at the end of each internal
Confluence link.

Add tests for internal links and add an example for internal links with
spaces in page titles to the README file.
This commit is contained in:
Bernd Ahlers 2023-03-31 11:09:58 +02:00
parent 6e4a912b11
commit 80d906417c
No known key found for this signature in database
4 changed files with 15 additions and 2 deletions

View File

@ -517,6 +517,8 @@ See task MYJIRA-123.
This is a [link to an existing confluence page](ac:Pagetitle) This is a [link to an existing confluence page](ac:Pagetitle)
And this is how to link when the linktext is the same as the [Pagetitle](ac:) And this is how to link when the linktext is the same as the [Pagetitle](ac:)
Link to a [page title with space](<ac:With Space>)
``` ```
### Add width for an image ### Add width for an image

View File

@ -276,9 +276,8 @@ func (r *ConfluenceRenderer) renderLink(writer util.BufWriter, source []byte, no
if err != nil { if err != nil {
return ast.WalkStop, err return ast.WalkStop, err
} }
return ast.WalkSkipChildren, nil
} }
return ast.WalkSkipChildren, nil
} }
return r.goldmarkRenderLink(writer, source, node, entering) return r.goldmarkRenderLink(writer, source, node, entering)
} }

View File

@ -1,5 +1,9 @@
<p>Use <a href="https://example.com">https://example.com</a></p> <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: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>Use footnotes link <sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup></p> <p>Use footnotes link <sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup></p>
<div class="footnotes" role="doc-endnotes"> <div class="footnotes" role="doc-endnotes">
<hr /> <hr />

View File

@ -2,5 +2,13 @@ Use <https://example.com>
Use <ac:rich-text-body>aaa</ac:rich-text-body> Use <ac:rich-text-body>aaa</ac:rich-text-body>
Use [page link](ac:Page)
Use [AnotherPage](ac:)
Use [Another Page](ac:)
Use [page link with spaces](<ac:Page With Space>)
Use footnotes link [^1] Use footnotes link [^1]
[^1]: a footnote link [^1]: a footnote link