$bod...">

Built-in custom merge macro

How to create a body merge macro that creates 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. 

Generate this HTML:

 <p>Before macro </p> <font color="red">macro body</font> <p>after macro.</p> 

How to remove <p></p> tags?

+6
source share
1 answer

This is a problem with Confluence. To avoid this, you should use html output. If the body or your macro contains wiki markup, you will have to display it manually. 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 need to change the regex if there are p tags in your macro that you want to keep. The regular expression in the code above will remove ALL p tags.

+3
source

Source: https://habr.com/ru/post/914051/


All Articles