Upgrading a very simple macro from Confluence 3.5 to 4.0

I have a very basic macro that is used on many, many pages in our Confluence 3.5 instance. I've read this page: Upgrading and Migrating an Existing Confluence Macro to 4.0 which is all very well for complicated macros that have been created as plugins.

My little macro was created entirely in the User Macro admin screen. It wraps a paragraph of text and displays a toc over on the right side of the page to save space.

The settings are:

  • Macro body processing: Render HTML
  • Output format: wiki markup
  • template:

and that's it.

My question is: do I have to go through all that rigmarole of creating a plugin (creating XML files and building a jar) in order to test a migration from 3.5 to 4.x to 5.x ?

3 answers

1 accepted

0 votes
Answer accepted
<ac:macro ac:name="section">
    <ac:macro ac:name="column">
      <ac:parameter ac:name="width">60%</ac:parameter>
    <ac:macro ac:name="column">
        <ac:macro ac:name="panel">
          <ac:parameter ac:name="bgColor">#FFF2F0</ac:parameter>
          <ac:parameter ac:name="borderColor">white</ac:parameter>
              <ac:macro ac:name="toc">
                <ac:parameter ac:name="style">circle</ac:parameter>
                <ac:parameter ac:name="maxLevel">3</ac:parameter>
              </ac:macro> </p>

You can add the above code to your Confluence 4.x user macro :) Ensure that the Macro Body Processing option is set to "Rendered"

How did I do this?

  • Create a new page, click Insert > Wiki Markup
  • Copy and paste your previous user macro template
  • Save the page
  • View the Storage Format (Tools > View Storage Format)

the point on doing the above is that, Confluence 4.x and above user macros do not use wiki markup anymore. So we need to use the equivalent of XHMTL code for that.

Thank you very much, Amalia. I'm a wiki-markup virtuoso, but I haven't had time to teach myself Confluence-flavoured XHTML. I appreciate your help with this.

To clarify - after migrating, will I be able to recreate that macro in the Admin screen in 4.0 in the same way as I created the original?

Update 1 - ensuring it appears in the macro browser

I've since learned that adding this line to the top of the code means the macro will be displayed in the macro browser, otherwise it doesn't appear.

## @noparams

Update 2 - it no longer recognises headings

But now I've got another problem with this macro. When it was built using wiki markup, you could have up to 3 levels of headings inside the left column, and they would appear in the table of contents in the usual way.

But if you use the macro as written above, headings don't render after you save the page. They're perfectly visible and formatted correctly while you're editing the page. But once the page is saved, the headings (a) disappear as if they don't exist and (b) are not in the table of contents.

This means the macro has lost functionality and I will have to manually edit 50+ pages to restore the headings that were in them.

So I've reverted back to the wiki-markup version of the macro. Any thoughts on why that might be happening?


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 12, 2019 in Confluence

Confluence Admin Certification now $150 for Community Members

More and more people are building their careers with Atlassian, and we want you to be at the front of this wave! Important Dates Start the Certification Prep Course by 2 April 2019 Take your e...

278 views 2 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you