Confluence text remove replace macro

Here’s a little user macro to replace text on page in Atlassian Confluence.

## @param old:title=Old text|required=true
## @param new:title=New text|required=false
<script>
AJS.toInit(function() {
  $('div.wiki-content').html($('div.wiki-content').html().replace(/$paramold/g,'$paramnew'));
});
 </script>

It uses jQuery to replace text on page. If the optional parameter is left blank, then the text will be removed.
Please note the the plugin runs inside the article body and doesn’t change text rendered by other macros, such as Blog Posts.
More elegant solution can be found here.

Leave a Comment