How do I specify a line break in a macro's body content?

Jim Bethancourt
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.
March 4, 2013

We're migrating from Confluence 3.5 to Confluence 5 and have a custom macro that renders its body content. We're using <br> tags in the macro body content, and they no longer seem to work (perhaps to prevent injection attacks?). How do I represent a line break in a macro body?

Thanks,

Jim

3 answers

1 accepted

0 votes
Answer accepted
Jim Bethancourt
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.
March 6, 2013

A big hack, but what worked was splitting the string on the <BR> tag in the Velocity template and putting a <br> after each token.

#if($person.title.contains("&lt;BR&gt;"))
    #foreach($token in $person.title.split("&lt;BR&gt;"))
        $token&lt;br&gt;
    #end
#else
    $!person.title
#end


0 votes
Jim Bethancourt
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.
March 7, 2013

One clarification that I forgot to add was that I am using a Velocity template renderer. I think the appropriate solution may be to follow the example of the com.atlassian.confluence.plugins.expand.ExpandMacro class. I'll try the approach it uses with another macro I need to migrade that uses a Velocity template and post an update here.

0 votes
Matthew J. Horn
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.
March 5, 2013

Is it possible that the XHTML parser is more strict in Confluence 5? Have you tried closing the <br> tag by making it <br/>?

Jim Bethancourt
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.
March 5, 2013

I'm guessing that's the case (possibly to prevent injection attacks). Unfortunately I had no luck with a <br/> tag either. :-(

Should I file a bug?

Matthew J. Horn
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.
March 5, 2013

Well, they work fine for me in 4.2. Could you post the entire macro so I can see how it's used? Maybe there's some funkyness that I'm not foreseeing...

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events