How to create a confluence macro with body that produces an inline output? The following macro:
## @noparams
<font color="red">$body</font>
applied to this text
Before macro [macro starts here]macro body[macro ends here] after macro.
Will create this HTML code:
<p>Before macro </p>
<font color="red">macro body</font>
<p>after macro.</p>
How to remove the <p></p>
tags?
User macros are useful if you want to create your own custom macros. These can be to perform specific actions, apply custom formatting and much more. User macros are created and managed within Confluence itself, you do not need to develop an app (plugin).
To add the Status macro to a page:From the editor toolbar, choose Insert > Other Macros. Choose Status from the Confluence content category. Enter a status and choose a color. Choose Insert.
You can try using shift + return (enter for windows) to insert a line break.
The Atlassian Community is here for you. Add the Excerpt macro to a page to define a snippet of content to be re-used on another page. This is great single sourcing important information. For example you could provide the contact details and dates from each project page on a summary page.
This is an issue with Confluence. To avoid this, you have to use html output. If the body or your macro contain wiki markup, then you will have to render this by hand. My workaround is as follows:
## Use this macro to avoid new lines:
#macro(doNothing)#end
##
## (Do stuff with body in wiki format, if appropriate)
##
## Convert to html and remove paragraph tags:
#set($renderedhtml = "")
#if ($body && ($body.length()>0))
#set($globalHelper = $action.getHelper())
#set($renderedhtml = $globalHelper.renderConfluenceMacro("$body").replaceAll("</?[pP]>",""))
#end
##
## (Do stuff with body in html format, if appropriate)
##
## Output text:
$renderedhtml#doNothing()
EDIT: You will want to modify the regex if there are p tags in your macro that you want to keep. The regex in the code above will remove ALL p tags.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With