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:
{section}{column:width=60%} 
$body 
{column}{column} 
{panel:bgColor=#FFF2F0|borderColor=white}{toc:style=circle|maxLevel=3}{panel} 
{column}{section}

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

This widget could not be displayed.
<ac:macro ac:name="section">
  <ac:rich-text-body>
    <ac:macro ac:name="column">
      <ac:parameter ac:name="width">60%</ac:parameter>
      <ac:rich-text-body>
        <p>$body</p>
      </ac:rich-text-body>
    </ac:macro>
    <ac:macro ac:name="column">
      <ac:rich-text-body>
        <ac:macro ac:name="panel">
          <ac:parameter ac:name="bgColor">#FFF2F0</ac:parameter>
          <ac:parameter ac:name="borderColor">white</ac:parameter>
          <ac:rich-text-body>
            <p>
              <ac:macro ac:name="toc">
                <ac:parameter ac:name="style">circle</ac:parameter>
                <ac:parameter ac:name="maxLevel">3</ac:parameter>
              </ac:macro> </p>
          </ac:rich-text-body>
        </ac:macro>
      </ac:rich-text-body>
    </ac:macro>
  </ac:rich-text-body>
</ac:macro>

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.

This widget could not be displayed.

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?

This widget could not be displayed.

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
Posted Monday in Confluence

Why start from scratch? Introducing four new templates for Confluence Cloud

Hi my Community friends!  For those who don't know me, I'm a product marketer on the Confluence Cloud team - nice to meet you! For those of you who do, you know that I've been all up in your Co...

475 views 6 6
Join discussion

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