I am writing a python script that creates an html body, then updates a confluence page with the html contents. For simplicity's sake, the html body can be divided into two sections: 1.) Overview and 2.) Details. The first html element of Overview should be a clickable link that navigates the user to the first html element of Details. I have implemented this as such
def generate_generic_html(...):
anchor_tag = ...
link = f'<h2><a href="#{anchor_tag}">{title} Overview</a></h2>'
overview_html = ...
overview_html = link + overview_html
link_location = f'<h1 id="{anchor_tag}">{title} Details</h1>'
details_html = ...'
body_html = link_location + details_html
return overview_html, body_html```
The html object are combined and posted to confluence via this method
status=confluence.update_page(pageID, confluencePage, html_body, parent_id=None, type='page', representation='storage', minor_edit=False)
The page successfully updates, and there is a clickable link. For example: if anchor_tag = foo, I can click on "foo Overview". And my browser tries to navigate to from https://org.atlassian.net/wiki/spaces/{space}/pages/{page_id}/{page_name} to https://org.atlassian.net/wiki/spaces/{space}/pages/{page_id}/{page_name}#foo-tag. However, the screen does not move.
For testing purposes, I also wrote the html body to a local file. The anchor tags in the local file worked as expected.
I know that it is possible to add anchor tags to confluence using the UI, but I am looking for a way to add these tags programmatically.
Thank you!
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.