In my instance of Confluence, I have a simple user macro that wraps whatever is inserted into it in a div. When I put a title and a paragraph into the content of the macro, the title is completely removed and the paragraph is stripped. However, if I include a second paragraph, then all of the content is rendered correctly.
Here is the macro:
## Macro title: DIV
## Macro has a body: Y
## Body processing: Rendered
## Output: HTML
## @param Class:title=Class|type=string|required=false|option-showNameInPlaceholder=false|option-showValueInPlaceholder=true
## @param Style:title=Style|type=string|required=false|option-showNameInPlaceholder=false|option-showValueInPlaceholder=true
<div class="$paramClass" style="$paramStyle">$body</div>
Here is the content that I am putting into the macro:
However, when the page is saved, the output removes the title and flattens the paragraph, leaving this:
In terms of HTML, this output looks like the following:
<div class="conf-macro output-inline" style="" data-hasbody="true" data-macro-name="div">This is the content.</div>
When I add a second paragraph, then the title and both paragraphs are rendered correctly, making the HTML on the rendered page look like this:
<div class="conf-macro output-inline" style="" data-hasbody="true" data-macro-name="div"><h2 id="Contracts-Title">Title</h2><p>This is the content.</p><p>Second paragraph.</p></div>
Here is the markup from the page's source for the macro:
<ac:structured-macro ac:macro-id="1014f412-f46d-475c-8308-1ba339d8390b" ac:name="div" ac:schema-version="1">
<ac:parameter ac:name="atlassian-macro-output-type">BLOCK</ac:parameter>
<ac:rich-text-body>
<h2>Title</h2>
<p>Content</p>
</ac:rich-text-body>
</ac:structured-macro>
I have tried removing all plugins, scripts, and styles from my Space but the behavior is the same.
Why is this simple macro changing the HTML content of its body at all let alone indiscriminately removing tags?
There is a bug ticket for this in JAC. It is CONFSERVER-24634. Feel free to vote on it and watch the ticket and hopefully it can get fixed.
I scoured Google (and I thought Atlassian's public JIRA...but maybe not) and I couldn't find this - thank you for digging it up, I'm glad to know at least that I'm not crazy!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Unfortunatley, it's a pretty old issue ... which does not bode well for getting fixed. But make sure to add your vote. If it gets enough votes hopefully it can get addressed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I thought I saw a workaround buried in the comments?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeah, it looks like the workaround is to have a blank paragraph inside the body of the macro ... not very elegant. I even tried doing this but no dice.
#set($body = $!body + "<p> </p>")
Looks like the header is stripped out of $body before even getting to the user macro. I verified that with the code block below which returns -1 ... meaning there is no header element in the string. : (
$body.indexOf("<h1>")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
/me scratches his head
I did some similar testing and found the same thing. So it's consistent at least.
The one thing I found is that if you change the body to "unrendered" then the h2 tag is present.
So something happens in the rendering phase of loading the body.
Oh wow... spent some time in script runner ... totally able to replicate the exact behavior.
Check this out:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Wow that's nuts that it even does it with ScriptRunner - that's what I would have done to circumvent the rendering process but I guess that's out -
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried with your macro and tested a bit and have to say, I have the same error and I'm just as confused as you are.
I asked the other community leaders, whether they have a possible solution for you.
Regards, Dominic
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.