Skip to content

Commit

Permalink
Fix custom link renderer and add tests for Confluence links
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bernd committed Mar 31, 2023
1 parent 6e4a912 commit 80d9064
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,8 @@ See task MYJIRA-123.
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:)

Link to a [page title with space](<ac:With Space>)
```

### Add width for an image
Expand Down
3 changes: 1 addition & 2 deletions pkg/mark/markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,8 @@ func (r *ConfluenceRenderer) renderLink(writer util.BufWriter, source []byte, no
if err != nil {
return ast.WalkStop, err
}

return ast.WalkSkipChildren, nil
}
return ast.WalkSkipChildren, nil
}
return r.goldmarkRenderLink(writer, source, node, entering)
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/mark/testdata/links.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<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>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">
<hr />
Expand Down
8 changes: 8 additions & 0 deletions pkg/mark/testdata/links.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,13 @@ Use <https://example.com>

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]
[^1]: a footnote link

0 comments on commit 80d9064

Please sign in to comment.