TOC macro: exclude header that is a placeholder
Asked by Adriel Liew:

I currently have a placeholder text "Add more" for a header and I would like to exclude it if the user does not fill it in. I've tried inputting Add.\* under exclude header but it doesn't work. "Add more" still shows as a header in the TOC.


Answers:
author: David Bakkers
body: Hello [@Adriel Liew](/t5/user/viewprofilepage/user-id/4774758)

I've just tested the Exclude Headings filter *Add.\** with the TOC macro, and it is working fine on Confluence Cloud:

![Annotation 2022-02-25 103001.png](https://community.atlassian.com/t5/image/serverpage/image-id/185337iAF3E8B8D27073E85/image-size/large?v=v2&px=999 "Annotation 2022-02-25 103001.png")

Chances are you have some other issue that is interfering. Double check the other settings for the TOC macro.

comments: author: Adriel Liew
body: Hi [@David Bakkers](/t5/user/viewprofilepage/user-id/1575730)

Strange, I tried doing it on a blank template and the placeholder text headings still show.

![template.png](https://community.atlassian.com/t5/image/serverpage/image-id/185364i316FF37AF2B6D3B2/image-size/large?v=v2&px=999 "template.png")![preview.png](https://community.atlassian.com/t5/image/serverpage/image-id/185365i4C77D44CF23D7CA2/image-size/large?v=v2&px=999 "preview.png")


author: David Bakkers
body: Are you saying the macro doesn't work properly when looking at a *template* or a *page* created from that template?

In the lower picture, the text headings "Add more H2" and "Add more H1" have suddenly disappeared from the page... yet the TOC macro is generating a list of headings as if they were still there! That is just plain bizarre!

I have also tested the TOC macro in a template, with and without the heading filter, and then looked at that template and it correctly filtered out all headings that started with "Add":

![Annotation 2022-02-25 180030.png](https://community.atlassian.com/t5/image/serverpage/image-id/185369iFE4B365605FA3F31/image-size/large?v=v2&px=999 "Annotation 2022-02-25 180030.png")

The TOC macros in pages based on that template work just fine too:

![Annotation 2022-02-25 181615.png](https://community.atlassian.com/t5/image/serverpage/image-id/185370i42F86F7275B555FC/image-size/large?v=v2&px=999 "Annotation 2022-02-25 181615.png")

I think you have some sort of content caching issue with your web browser, as the macro seems to be 'lagging' behind what is actually on the page. Try another browser for that same page and see if the macro there also doesn't correctly filter out the headings that start with "Add".


author: Adriel Liew
body: Wait let's go back to my story.

I'm creating a template with some text headings and placeholder headings.

When the users use the template to create a new page, assuming they fill in the placeholder text headings with "xxx" if it's applicable, and leave them blank when it's not, I want the page's TOC to show the headers that are filled and those blank (still placeholders) to be excluded.

Hopefully this makes sense.

and yes I do think that that is bizarre that the TOC is showing the placeholder headings.

and yes I tried using Edge browser and it's happening there too.


author: David Bakkers
body: Sorry, but I'm out of ideas, as all the combinations I've tested all work perfectly and I have no idea why the same would not work for you, nor how the TOC macro is generating a list of headings when they aren't even on the page.

There are more strange things on the template / page screen grab you've supplied:

1. The first line "H1", which I assume is the style Heading1, has black text, but the third line "Add more H1", which I assume is also the style Heading1, is grey.
2. The second line "Add more H2", which I assume is the style Heading2, is grey text, but the fourth line "H2", which I assume is also the style Heading2, is black.

I have no idea why lines of text that are formatted with the same heading style are changing colour.

If you are in a corporate environment, maybe someone might have changed the default style and it's damaged how it interacts with the TOC macros?

Do all the usual testing, such as a web browser outside your corporate LAN to eliminate proxy / firewall caching issues. Get others to test via their web browsers. Get another developer to double check your work etc.

Other than that, you've got a very funky problem that you will need deeper investigation with your ITS department and even Atlassian to unravel


author: Adriel Liew
body: > There are more strange things on the template:
>
> 1. The first line "H1", which I assume is the style Heading1, has black text, but the third line "Add more H1", which I assume is also the style Heading1, is grey.
> 2. The second line "Add more H2", which I assume is the style Heading2, is grey text, but the fourth line "H2", which I assume is also the style Heading2, is black.
>
> I have no idea why lines of text that are formatted with the same style are changing colour.

Wait isn't that normal? I'm using the placeholder text. Here's a GIF on what I did:

![placeholder.gif](https://community.atlassian.com/t5/image/serverpage/image-id/185372iC3A569B323B217B3/image-size/large?v=v2&px=999 "placeholder.gif")


author: David Bakkers
body: Ahhh, OK, now it makes sense. When you use the words 'placeholder' or 'placeholder text' you don't mean the normal English language meaning of those words, you mean you're using the *Placeholder text **MACRO***.

Yes, that is the expected behaviour. The Placeholder text macro will display no text on the destination page ++until you put a value into it++. However, if that Placeholder text macro has also been styled as a Heading, the TOC macro can 'see' it. Unfortunately, in the absence of a value, it has no choice but to read the hidden, temporary value of the Placeholder text macro and put that into the table. It can't apply the exclusion rule on text that doesn't exist yet.

The only way to avoid this is to not use the Placeholder Text macro, but just put plain old text on the template page, style it as a Heading and start it with the text "Add more", then hope your users are smart enough to work it out. When I want this sort of traditional 'placeholder' text on a page that I want a user to change, I put that text inside square or curly brackets, to make it fairly obvious to the user to change it to the real value.

I suggest you then search through the [Confluence Cloud Feature Requests](https://jira.atlassian.com/issues/?filter=98690) to see if someone else has already noted that limitation of the TOC macro when used with the Placeholder text macro to see if it's already raised as a bug or feature request.


author: Adriel Liew
body: Ah OK I see!

I was assuming my users to not be as smart as I think they are so I wanted to use the placeholder text **macro**. I guess not being able to use the placeholder text macro as a heading is kind of a "limitation" for the TOC macro then. Thank you for your help!


Tags: cloud

confluence-cloud

table-of-contents