Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Regex OR operator and Macro Markup Parameter/Value Pairs in Sidebar

Nicole Norman December 11, 2018

Hi,

I want to use the Table of Contents (TOC) macro in the sidebar. I want to exclude all headings that end in "headingABC" and all headings that end in "headingDEF".

Key Items of Note :
- Wiki markup for macros use the pipe key to separate parameter/value pairs.
- Regex uses the pipe key as the OR operator within an expression.

Issue :
When I add an OR operator (pipe key) to the exclude parameter value it is effectively being interpreted as the end of the exclude parameter value rather than being interpreted as the OR operator within the expression value of the exclude parameter.

STRs

1. Create a page, add text for "headingABC" and "headingDEF" then set both to H1 (level is irrelevant). Click update to save the page.

2. Navigate to the space sidebar textarea (space tools > look and feel > sidebar, header, and footer) and copy/past the TOC markup {toc:exclude=.*headingABC|.*headingDEF} in the textarea and click save to save the sidebar.

3. Load the page created in step 1 and view the content rendered by the TOC macro.

//end STRs

Actual Result : Only the first heading added in the exclude is actually excluded.

Expected Result : All the headings specified in the exclude parameter should be excluded.

I have tried some variations including escaping the pipe {toc:exclude=.*headingABC\|.*headingDEF}, double escapes, double pipes, double rainbows, quotes in various places, and more but haven't yet gotten multiple expressions using the OR operator to exclude multiple headings in the sidebar. Works as expected when the TOC is in the page rather than the sidebar, however.

What's the markup that would accomplish this?

Thanks,

Nicole

1 answer

1 accepted

0 votes
Answer accepted
Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 11, 2018

I cannot seem to find away around the pipe issue. But what about if you rewrite the expression to this ...

{toc:exclude=.*heading(ABC)?(DEF)?}
Nicole Norman December 11, 2018

Thank you for the prompt reply!  That does exclude those headings however the example I provided was oversimplified.  The heading titles I want to pass in won't have a partial string match in common (the 'Heading' prefix).  I need to pass multiple disparate strings.  For example, I want to exclude (The list is likely to grow.) :

pen

banana

fred

sky

blanket

Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 11, 2018

Would this work then?

{toc:exclude=.*(pen)?(banana)?(fred)?(sky)?(blanket)?(etc)?}
Nicole Norman December 11, 2018

It does work but it's too robust.  We are going to go with this for more precision :

{toc:exclude=^(pen)?(banana)?(fred)?(sky)?(blanket)?(etc)?$}

Thanks again!

Like Davin Studer likes this
Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 11, 2018

Like the saying goes ...

"You have a problem and you want to solve it using Regular Expressions. Now you have two problems."

: )

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events