Hello Folks,
I have the following custom user macro:
Macro Body Processing = No Macro Body
## @param Name:title=Name|type=string|required=false|desc=Title of term to display
#if($param0) #set($termName=$param0) #end
#if($paramName) #set($termName=$paramName) #end
#if($termName)
<ac:macro ac:name="report-block">
<ac:parameter ac:name="injected">true</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<ac:macro ac:name="content-reporter">
<ac:parameter ac:name="scope">SITE:Terms > children</ac:parameter>
<ac:parameter ac:name="matchAll">true</ac:parameter>
<ac:parameter ac:name="type">page</ac:parameter>
<ac:parameter ac:name="space">+SITE</ac:parameter>
<ac:parameter ac:name="key">content:children</ac:parameter>
<ac:rich-text-body>
<ac:macro ac:name="text-filter">
<ac:parameter ac:name="include">$termName</ac:parameter>
<ac:default-parameter>content:title</ac:default-parameter>
</ac:macro>
</ac:rich-text-body>
</ac:macro>
<ac:macro ac:name="report-body">
<ac:rich-text-body>
<ac:structured-macro ac:name="html" ac:schema-version="1">
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:plain-text-body><![CDATA[<span style="border: 3px outset blue;" onmouseover="this.style.border='3px inset blue';" onmouseout="this.style.border='3px outset blue';"><a title="%data:definition%">%content:title%</a></span> ]]></ac:plain-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:macro>
<ac:macro ac:name="report-empty">
<ac:rich-text-body>$termName</ac:rich-text-body>
</ac:macro>
</ac:rich-text-body>
</ac:macro>
#else
<span style="color: red;">Search term required, see this page for more info:
<ac:link>
<ri:page ri:content-title="Terms" ri:space-key="TOOL"/>
<ac:plain-text-link-body><![CDATA[Terms]]></ac:plain-text-link-body>
</ac:link>
</span>
#end
For some reason, when the text is rendered on the page, it has <p> tags surrounding it. So, it shows up on its own line instead of inline as I've specified.
I downloaded and installed the Confluence Source Editor add-on. I opened the source editor on the affected page, and tried to remove the <p> tags manually, but they are not there. Here is a portion of the source code:
<p>SPAN is brought to you by the Agency Principles and Processes for Software (APPS) project team.</p>
<p>SPAN is a compendium of Processes, Procedures, Job Aids, Examples and other recommended best practices. Working hand in hand with the <ac:structured-macro ac:macro-id="cecdbfe5-c0a8-4445-9215-b3782b459aac" ac:name="term" ac:schema-version="1">
<ac:parameter ac:name="Name">SWEHB</ac:parameter>
</ac:structured-macro> Software Engineering Handbook <sup>
<ac:link ac:anchor="References">
<ac:plain-text-link-body><![CDATA[002]]></ac:plain-text-link-body>
</ac:link>
</sup> and the collection of Engineering Principles, these assets are intended to facilitate the software development process Agency wide.</p>
Is there any way to remove these <p> tags? Is my code wrong? It worked in Confluence 5.8.18 just fine. Any suggestions are greatly apprectiated. Thanks!
Chris Martino
Hello Shannon,
Sorry for the late reply!
Funny thing: the link you sent me is actually a question that I asked years ago when upgrading from Confluence 3.5 to Confluence 4.2. I re-read through the post, and I tested the suggestion by Matt Horn, but I could not get it work. When I add my custom removeptags macro to the page, I get an error that says: "Error rendering macro 'removeptags' : Error occurred rendering template content"
Here's my remove p tags macro code:
Macro Body Processing: No macro body
## @param Term:title=term|type=string|required=true|desc=Enter term
#set($xhtml=$helper.renderConfluenceMacro("{term:$paramTerm}"))
## remove leading <p> and trailing </p>
#if($xhtml.startsWith("<p>",0) && $xhtml.endsWith("</p>"))
#set($len=$xhtml.length()-$generalUtil.convertToInteger(4))
#set($xhtml=$xhtml.substring(3,$len))
#end
${xhtml}
Do you know what I'm doing wrong?
Chris
Chris,
Oh no! Sorry for that. I hadn't even realized it was posted from you.
Can you just confirm with us which version of confluence you're currently running? I saw you said it worked in 5.8.18 so I assume this means you upgraded recently? Are you in the latest version?
Kind Regards,
Shannon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shannon,
No problem! It took me awhile to recognize it as well.
I am now using Confluence 6.2.3. This became a problem after upgrading.
Chris
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, Chris!
Looks like it might be related to these bugs:
They're both closed but there are a lot of comments that it's still a problem so I want to reopen it. Can you just first confirm if you do not specify rich text, does the issue go away?
Kind Regards,
Shannon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Christopher,
This sounds similar to an issue mentioned at another community question:
- are macros now always wrapped in tags?
There are a few suggestions there on how to remove the added tags. Perhaps you can have a look and see if it's useful for your case?
Kind Regards,
Shannon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Shannon,
Sorry for the late reply!
Funny thing: the link you sent me is actually a question that I asked years ago when upgrading from Confluence 3.5 to Confluence 4.2. I re-read through the post, and I tested the suggestion by Matt Horn, but I could not get it work. When I add my custom removeptags macro to the page, I get an error that says: "Error rendering macro 'removeptags' : Error occurred rendering template content"
Here's my remove p tags macro code:
Macro Body Processing: No macro body
## @param Term:title=term|type=string|required=true|desc=Enter term
#set($xhtml=$helper.renderConfluenceMacro("{term:$paramTerm}"))
## remove leading <p> and trailing </p>
#if($xhtml.startsWith("<p>",0) && $xhtml.endsWith("</p>"))
#set($len=$xhtml.length()-$generalUtil.convertToInteger(4))
#set($xhtml=$xhtml.substring(3,$len))
#end
${xhtml}
Do you know what I'm doing wrong?
Chris
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.