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
{code}
## @noparams
<ac:structured-macro ac:name="html">
<ac:plain-text-body><![CDATA[
<style>
ul#WORDTOC .h1 {
font-weight: bold;
margin-top:6px
}
ul#WORDTOC .h2:before,
ul#WORDTOC .h3:before,
ul#WORDTOC .h4:before ,
ul#WORDTOC .h5:before ,
ul#WORDTOC .h6:before{
content:'\2022';
padding-right:6px;
}
ul#WORDTOC .h2{
margin-left:12px
}
ul#WORDTOC .h3{
margin-left:24px
}
ul#WORDTOC .h4{
margin-left:36px
}
ul#WORDTOC .h5{
margin-left:48px
}
ul#WORDTOC .h6{
margin-left:60px
}
</style>
<script>
AJS.toInit(function () {
var saidHello = false;
AJS.$('.converter-macro-ajax-container').ajaxStop(function(){
runOnce();
});
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 = [].slice.call(documentRef.body.querySelectorAll('.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());
div.appendChild(link);
toc.appendChild(div);
heading.parentNode.insertBefore(anchor, heading);
});
saidHello = true;
}
});
</script>
]]></ac:plain-text-body>
</ac:structured-macro>
{code}
Matthew Beda
Senior Application Engineer
1 accepted answer
1 comment