Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

TOC macro use to show Headings in embedded word docs

Create a User Macro : No Macro Body

This is to be used in conjunction with the TOC Macro and will append to the TOC Macro

## @noparams
<ac:structured-macro ac:name="html">
ul#WORDTOC .h1 {
font-weight: bold;

ul#WORDTOC .h2:before,
ul#WORDTOC .h3:before,
ul#WORDTOC .h4:before ,
ul#WORDTOC .h5:before ,
ul#WORDTOC .h6:before{

ul#WORDTOC .h2{
ul#WORDTOC .h3{
ul#WORDTOC .h4{
ul#WORDTOC .h5{
ul#WORDTOC .h6{
AJS.toInit(function () {
var saidHello = false;
function runOnce(){
if (!saidHello) htmlTableOfContents();
function htmlTableOfContents (documentRef) {
AJS.$('.toc-macro').append("<ul id='WORDTOC'></ul>");
var documentRef = documentRef || document;
var toc = documentRef.getElementById('WORDTOC');
var headings = []'.office-container h1, .office-container h2, .office-container h3, .office-container h4, .office-container h5, .office-container h6'));
headings.forEach(function (heading, index) {
var anchor = documentRef.createElement('a');
anchor.setAttribute('name', 'toc' + index);
anchor.setAttribute('id', 'toc' + index);

var link = documentRef.createElement('a');
link.setAttribute('href', '#toc' + index);
link.textContent = heading.textContent;

var div = documentRef.createElement('div');
div.setAttribute('class', heading.tagName.toLowerCase());

heading.parentNode.insertBefore(anchor, heading);
saidHello = true;


1 comment

Bill Bailey Community Leader Oct 15, 2021

@Matthew Beda very interesting.  I think this would work very well as an article where you go through the theory of how it works to help the user community out there.  Some examples of ones I wrote:


Log in or Sign up to comment
Community showcase
Published in Confluence Cloud

🏠 Say hello to the new Confluence Home!

Hi Atlassian Community, My name is DJ Chung, and I’m a Product Manager on the Confluence Cloud team. Today, I’m excited to share a new and improved version of Home. The new Home helps you ...

38,877 views 28 126
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you