Forums

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

Replace text with excerpt include - Macro

Thomas Scheer
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 12, 2023

Is there any way to replace a specific text in all confluence pages of a space with a specific "excerpt include" which is defined in the space?

 

e.g.     ###text###  -->   "excercpt include ###text###"   in all pages.

 

The default search replace can only replace text with text.

 

1 answer

1 vote
Andrii Maliuta
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.
July 12, 2023

Hello @Thomas Scheer ,

Yes, you can use Java API (https://developer.atlassian.com/server/confluence/) to do this.

You first get pages you want to apply changes to and then change their bodies.

E.g.  in Groovy :

List<Page> pages = pageManager.getPages(...);

pages.each { page ->

def body = page.getBodyAsString()
body = body.replace("TEXT", "<ac:structured-macro ac:name=\"excerpt-include\"...</ac:structured-macro>")
page.setBodyAsString(body)

}


Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events