Forums

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

Bulk find and replace of text within Markdown macro container throughout the whole space

Stan Ry
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.
October 17, 2019

Hello,

We are using Markdown macro on Confluence pages to extend page functionality. Within these macro we use some HTML code patches that allow us to add some custom formatted admonitions, information banners and likes. 

I want to replace some text in bulk within these macros. For example, within these instances of Marcdown macros I have links like <a href="https://example.net/pages/viewpage.action?pageId=12345"></a> and I need them replaced with <a href="https://example.net/pages/viewpage.action?pageId=98765"></a>.

I have administrative access to this instance. 

I am using PgAdmin and the following clause to update the 'bodycontent'  table that as far as I know contains the page content published in Conflence:

UPDATE bodycontent SET body = replace(body, 'example.net/pages/viewpage.action?pageId=12345', 'https://example.net/pages/viewpage.action?pageId=98765') where contentid = '2552552';

This works perfect but only when the content I replace is outside the Markdown macro.

If I add the https://example.net/pages/viewpage.action?pageId=12345 link within the text body of a Confluence page, the above replacement clause works fine. After purging Confluence cache and updating the page with pageId=2552552 I see the changes have taken their place and the new https://example.net/pages/viewpage.action?pageId=98765 address shows on the page.

 However if the same text that I want to replace resides inside an instance of a Markdown macro contained on the page, the replacement clause does not affect the page

That's what I do step by step.

1. Execute the clause:

UPDATE bodycontent SET body = replace(body, 'example.net/pages/viewpage.action?pageId=12345', 'https://example.net/pages/viewpage.action?pageId=98765') where contentid = '2552552';

2. Check that it worked on the table by executing following:

select * from bodycontent where body like '%https://example.net/pages/viewpage.action?pageId=98765%' and contentid = '2552552';

This clause ALWAYS returns the result with the target https://example.net/pages/viewpage.action?pageId=98765. So it feels as if updated worked fine.

3. Clear cache on the /cache/showStatistics.action page.

4. Update page in browser.

Nothing. Nada. Ni suquiera un caracter.

It feels like update works fine. And data in bodycontent does in fact change. However, when you refresh the page, the Markdown macro fetches its old data from some other table. In other words, it feels like when you update the target page in the browser, Markdown macro updates the bodycontent table and overwrites changes made to it with UPDATE clause.

What could be the issue here? Any clues? I need to do nearly 1K+ changes on Confluence pages, and doing it manually really makes me sick.

Thank you.

Stan. 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events