I am parsing dita xml and I have to generate Confluence Storage Format.
I am facing difficulty with Anchor macro, while dita format have xref who behave the same way as html local link <xref href="#id">title</xref>....<any id="id"..., confluence seam to have its own unique synthax. 
Did someone have any good example on how to build a correct anchor and link it properly?
I finally figured it out.
Instead of id on an element, we insert an anchor were the link should send the user, I inserted it just above the header.
<ac:structured-macro ac:name="anchor"><ac:parameter ac:name="">The_Id</ac:parameter></ac:structured-macro>
And anchor link are built like these.
<ac:link ac:anchor="The_Id"><ac:plain-text-link-body><[CDATA[text describing the link]]></ac:plain-text></ac:link>
Tested on Confluence 5.7
The anchor macro actually creates a HTML <span> element which has an ID that contains the title of the page and the anchor.
<span id="CONFLUENCEPAGENAME-ANCHORNAME" class="confluence-anchor-link"></span>
So, if your confluence page represents a topic, that should be quite easy to implement (Because CONFLUENCEPAGENAME equals your topic title or key or ID or whatever you use). Just Create an empty confluence page, add an anchor macro, save it and examine the rendered HTML.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With