TOC Macro - Exclude Specific Headings
Asked by Mick Davidson:

Afternoon,

I'm using the TOC macro in 4.3.7 Download (in Firefox), and want to exclude all H2s. However, the only way to do this seems to be take a degree in programming. IE, the documentation tells you to look here: [](http://download.oracle.com/javase/1.5.0/docs/api/java/util/regex/Pattern.html)<http://download.oracle.com/javase/1.5.0/docs/api/java/util/regex/Pattern.html>

The contents of this page will mean nothing to your average user. So two things:

1. Who thought this was an acceptable way to 'help' people?
2. Why can't I just add something simple like h1, h2 etc to the Exclude Headings field?

If anyone knows how to set this up without taking three years to go back to university, I'd be most grateful to know how it works. :)

Cheers.


Answers:
author: Yvonne Gutenberger
body: In case anyone else is looking for an idea here, I found this thread particularly helpful: <https://community.atlassian.com/t5/Confluence-questions/TOC-Macro-Exclude-two-headings-with-different-names/qaq-p/95702>


author: jing_hwa_cheok
body: Hi Mick,

<br />

You can exclude certain heading by specifiying the Minimum Heading Level and the Maximun Heading Level in the table of macro configuration.

![](../../upfiles/sample_10.png)

<br />

<br />

As explain the field description it allow you to exclude certain heading which are lower than the minimun and higher than the maximun level.

<br />

Regards,  
Jing Hwa

comments: author: Mick Davidson
body: Thanks.

Following on from this, I've been using the Exclude Headings field to exclude specific headings. However, this only works on the first heading you enter. If you add a second, seperated by a comma, it is ignored. Is this expected behaviour?

The text under this field says:
> If set, any headings that match the regular expression are ignored. Example: .\*\\.\[1//2\]

This makes no sense whatsoever. So what is the use of this info? What am I supposed to undertsand by it? For a start, why would any of these chars be in my headings? Or are they supposed to be something that has gotten mangled when rendered?

Cheers.


author: Bill Goodall
body: Mick i share your confusion. Here is where I am looking for some help. Regular Expressions: I have to say, that I think the use of regular expressions could be powerful here, however I am not sure how to actually implement them. I tried to copy the text into RegExHero and then attempted your example and a few of my own, but I had no effect. Does anyone from Jira think they could explain what the example demonstrates? What is: .\*\\.\[1//2\] Supposed to return? Is that supposed to select all level 1 and level 2 headers? Do you think that some Jira expert could provide an example of selecting the correct headers, or that they could update the help documentation to provide some text and then show us how they would exclude or include it? CSS Classes or HTML Heading Levels Alternatively It would seem more consistent with how the editor tool is used to make the TOC inclusion/exclusion work based on the existing Heading levels \<H2\> \<H3\> that you have us selecting, or some custom classes that could be applied through your templates and tools. Is there already a feature request for that?


author: Dmitriy Alekseev
body: For any case read <https://www.geany.org/manual/gtk/glib/glib-regex-syntax.html>

For my case I need regex for exclude any paragraf that befin from space, and resolution is:

(\^\[\\s\])


author: Darren K
body: Same problem here too ...

I simply need to exclude several headings and expected to enter them in the Exclude Headings field separated by commas.

I'm a documenter not a programmer. Why is this simple task so ridiculously difficult?

Has anyone found a simple solution?

Thanks,

Darren.


author: Rhocela Pasigna
body: Same problem here... has any one figured this out?


Tags: exclude

heading

macro

table-of-contents