Home/Confluence storage format reference
Confluence storage format
toc and toc-zone macros in Confluence storage format
The toc macro lists the headings of the current page, and toc-zone limits the list to a marked section. Both are generic Confluence extensions in ADF. Their parameters pass through unchanged, only reordered.
Storage format
<ac:structured-macro ac:name="toc"/>
<ac:structured-macro ac:name="toc"><ac:parameter ac:name="maxLevel">2</ac:parameter><ac:parameter ac:name="minLevel">1</ac:parameter><ac:parameter ac:name="style">square</ac:parameter><ac:parameter ac:name="type">flat</ac:parameter><ac:parameter ac:name="outline">true</ac:parameter><ac:parameter ac:name="exclude">Intro</ac:parameter></ac:structured-macro>
<ac:structured-macro ac:name="toc-zone"><ac:rich-text-body><h2>Zone heading</h2></ac:rich-text-body></ac:structured-macro>
In the editor
| How | Note |
|---|---|
| Select the insert button, or type / and pick the macro by name | Per the Atlassian documentation. Both macro pages describe the same steps. |
As ADF (Confluence Cloud)
The ADF that Confluence Cloud builds for:
<ac:structured-macro ac:name="toc"><ac:parameter ac:name="maxLevel">2</ac:parameter><ac:parameter ac:name="minLevel">1</ac:parameter><ac:parameter ac:name="style">square</ac:parameter><ac:parameter ac:name="type">flat</ac:parameter><ac:parameter ac:name="outline">true</ac:parameter><ac:parameter ac:name="exclude">Intro</ac:parameter></ac:structured-macro>
{
"type": "doc",
"content": [
{
"type": "extension",
"attrs": {
"extensionType": "com.atlassian.confluence.macro.core",
"extensionKey": "toc",
"parameters": {
"macroParams": {
"maxLevel": {
"value": "2"
},
"minLevel": {
"value": "1"
},
"outline": {
"value": "true"
},
"_parentId": {
"value": "<page id>"
},
"style": {
"value": "square"
},
"exclude": {
"value": "Intro"
},
"type": {
"value": "flat"
}
},
"macroMetadata": {
"macroId": {
"value": "<id>"
},
"schemaVersion": {
"value": "1"
},
"title": "Table of Contents"
}
}
}
}
],
"version": 1
}
Examples
Storage format sent
<ac:structured-macro ac:name="toc"></ac:structured-macro>Add a contents list with all defaults. The stored page shows an empty client-side placeholder that the browser fills in.
Rendered view (HTML)
<div class="toc-macro client-side-toc-macro conf-macro output-block" data-hasbody="false" data-headerelements="H1,H2,H3,H4,H5,H6,H7" data-macro-id="<id>" data-macro-name="toc"> </div>Storage format after the round trip through ADF
<ac:structured-macro ac:name="toc" ac:schema-version="1" ac:macro-id="<id>" />Sent to Confluence Cloud on .
Storage format sent
<ac:structured-macro ac:name="toc"><ac:parameter ac:name="maxLevel">2</ac:parameter><ac:parameter ac:name="minLevel">1</ac:parameter><ac:parameter ac:name="style">square</ac:parameter><ac:parameter ac:name="type">flat</ac:parameter><ac:parameter ac:name="outline">true</ac:parameter><ac:parameter ac:name="exclude">Intro</ac:parameter></ac:structured-macro>Restrict the list to levels 1 and 2, with square bullets, a flat layout, outline numbering and an excluded heading.
Rendered view (HTML)
<div class="toc-macro client-side-toc-macro conf-macro output-block" data-cssliststyle="square" data-excludeheaderregex="Intro" data-hasbody="false" data-headerelements="H1,H2" data-macro-id="<id>" data-macro-name="toc" data-numberedoutline="true" data-structure="flat"> </div>Storage format after the round trip through ADF
<ac:structured-macro ac:name="toc" ac:schema-version="1" ac:macro-id="<id>"><ac:parameter ac:name="maxLevel">2</ac:parameter><ac:parameter ac:name="minLevel">1</ac:parameter><ac:parameter ac:name="outline">true</ac:parameter><ac:parameter ac:name="style">square</ac:parameter><ac:parameter ac:name="exclude">Intro</ac:parameter><ac:parameter ac:name="type">flat</ac:parameter></ac:structured-macro>Sent to Confluence Cloud on .
Storage format sent
<ac:structured-macro ac:name="toc-zone"><ac:rich-text-body><h2>Zone heading</h2></ac:rich-text-body></ac:structured-macro>Create a contents list for one section only. The zone rewrites its headings with anchors and adds its own list.
Rendered view (HTML)
<div class="conf-macro output-block" data-hasbody="true" data-macro-name="toc-zone" data-macro-id="<id>"><style type="text/css">/*<![CDATA[*/
div.rbtoc1795972092663 {padding: 0px;}
div.rbtoc1795972092663 ul {list-style: disc;margin-left: 0px;}
div.rbtoc1795972092663 li {margin-left: 0px;padding-left: 0px;}
/*]]>*/</style><div class="toc-macro rbtoc1795972092663">
<ul class="toc-indentation">
<li><a href="#Examplepage-Zoneheading">Zone heading</a></li>
</ul>
</div><h2 id="Examplepage-Zoneheading">Zone heading</h2><style type="text/css">/*<![CDATA[*/
div.rbtoc1795972092663 {padding: 0px;}
div.rbtoc1795972092663 ul {list-style: disc;margin-left: 0px;}
div.rbtoc1795972092663 li {margin-left: 0px;padding-left: 0px;}
/*]]>*/</style><div class="toc-macro rbtoc1795972092663">
<ul class="toc-indentation">
<li><a href="#Examplepage-Zoneheading">Zone heading</a></li>
</ul>
</div></div>Storage format after the round trip through ADF
<ac:structured-macro ac:name="toc-zone" ac:schema-version="1" ac:macro-id="<id>"><ac:rich-text-body><h2>Zone heading</h2></ac:rich-text-body></ac:structured-macro>Sent to Confluence Cloud on .
Storage format sent
ADF:{"content": [{"attrs": {"extensionKey": "toc", "extensionType": "com.atlassian.confluence.macro.core", "parameters": {"macroParams": {}}}, "type": "extension"}], "type": "doc", "version": 1}Save an ADF extension node for toc. An empty parameter object is enough to make the macro.
Rendered view (HTML)
<div class="toc-macro client-side-toc-macro conf-macro output-block" data-hasbody="false" data-headerelements="H1,H2,H3,H4,H5,H6,H7" data-macro-id="<id>" data-macro-name="toc"> </div>Storage format after the round trip through ADF
<ac:structured-macro ac:name="toc" ac:schema-version="1" ac:macro-id="<id>" />Sent to Confluence Cloud on .
What changes in conversion
- toc maps to an ADF extension with extensionType com.atlassian.confluence.macro.core and extensionKey toc. toc-zone maps to a bodiedExtension with the key toc-zone.
- Every parameter tested came back with the same value: maxLevel, minLevel, outline, style, exclude and type. Only their order changed.
- A toc with no parameters is returned as a self-closing macro.
- In ADF the macro parameters sit under macroParams, and Confluence adds a _parentId entry that is not part of the storage format.
- The contents list is built when the page is shown, so neither format holds the list of headings.
Pitfalls
- The toc macro scans its own page only. Use toc-zone when the list must cover one part of a page.
- The documentation describes exclude and include as case sensitive. Match heading text exactly.
- The documentation separates several headings with a vertical bar in the exclude and include values, as in Overview|Summary.
Questions and answers
What are the defaults for heading levels?
The toc page gives 1 to 6, and the zone page gives a minimum of 1 and a maximum of 7.
Is a toc stored with its entries?
No. The stored view is an empty div with data attributes that the page script fills in.