Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Confluence Storage Format - Anyone played with anchor and anchor-link macro

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?

like image 987
Saloparenator Avatar asked Oct 29 '25 10:10

Saloparenator


2 Answers

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

like image 103
Saloparenator Avatar answered Oct 30 '25 23:10

Saloparenator


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.

like image 21
Stefan Eike Avatar answered Oct 30 '25 23:10

Stefan Eike



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!