Has anybody successfully managed to exclude headings from the TOC that have different names? For example if I want to exclude the two following headers from my TOC
Issues
Management
what RegEx would I use?
Not as simple as taking those entries off Heading 1 I guess?
I wish I need to keep them just exclude them from the TOC. I have seen examples of excluding one heading, but not two.
You can use this:
(Issues|Management).*
Steffen,
thank you for the help. This was exactly what I was looking for.
Steven
WOO HOO - Steffen Heller's solution works very nicely!! Thank you!!
WOO HOO double!
Steffen, thank you, that worked. I agree with other people, the Confluence help for this is appalling and totally unhelpful. The help in the macro is absolutely useless and has been for years. Why this hasn't been fixed is beyond me.
@Atlassian: see the complaints below and fix the documentation which is years out of date. This should be a simple task to do. users shouldn't have to "See Sun's Regex documentation for examples of constructing regular expression strings." Even if they were developers they shouldn't have to, let alone the rest of us!
@Atlassian ditto. Wasted an hour on the help doc before finding this page
An update to the doco would be useful. It's such a simple solution and should be on the TOC doco page.
Massively agree with these comments. Presumably a feature designed by a developer, not an end user.
IN fact the regex seems broken: just get "Error rendering macro 'toc' : null" applying a similar regex.
I agree. Atlassian's documentation that refers people to Sun's RegEx docuemntation is woefully inadequate. I think all they would need to do to appease 95% of users who just want to exclude a handful of names from the TOC list is add a few examples:
(Issues|Management)
(Issues|Management|Examples|Revision History)
A few simple examples would explain how to use the exclusion feature for the vast majority of users.
This solved my woes. Thank you.
Worked perfect for me - thanks to @Steffen Heller
-> Maybe you can also help me with a problem belonging to this trouble here
Problem:
I can't use a specific word, there are several questions on the page which start with different words -> is there an opportunity to exclude h2 after the used (Recent).* excluding?
Thanks!
Complex question, To make it short, I don't think that what you want is possible as those regular expressions only refer to the headline text but not any kind of underlying source code.
Possible workaround?
Would it be possible to add a consistent prefix to the questions e.g. having all questions start with "Q:"?
PS: I am not an expert on that, just a normal user that was searching for a solution and posted it here (years ago ;-))
Thanks for your answer!
No expert? That's impossible because you solved a problem many people had.
Workaround sounds good, but i'm afraid that starting with a certain kind of letter is impossible.
But I will try and post my results!
Made a workworkaround:
Not very elegant, but worked. So all questions (which have heading 3) will not be shown.
I tried exclude with a certain ending (in my case '?' -> because all questions should end with ?) by using .*? -> did not work
Some general thoughts:
Although regular expressions can be quite complex, a few simple rules are probably enough to know how to use them in the table of contents macro.
What is most important to know, is this:
The combinatin of both is .* and that stands for basically every combination of numbers and letters, e.g. "a", "1", "abc", "123", "abc 123 xyz", but also "" (nothing at all = a letter or number that occurs zero times).
And so
Thank you so much for this amazing informations according 'include' and 'exclude' parameters in Table of Contents Macro -> Should be transferred right into documentation!
That helps a lot and offers the opportunity to find the best solution by your own.
In my case I had to exclude headings "Date" and "Table of Content". This is what I entered in the "Exclude Headings" field and that worked:
Date|Table of Contents
Notes:
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])
Following up on Steffen Heller's response from Nov 14, 2017:
To suppress "Why Are We Writing This?", I had to use Why.* in Exclude Headings. I guess question mark (?) counts as a non-letter!
My response from Nov 13, 2017 (perhaps Nov 14 in other parts of the world) should work:
But since ? is part of the regular expression syntax you must escape it.Try .*\? (add \ before the ?) and it should work ;-)
But since ? is part of the regular expression syntax you must escape it.
Try .*\? (add \ before the ?) and it should work ;-)
In other words:
.*\? will exclude headlines that end with a question mark (?).
It looks like you're new here. Sign in or register to get started.