I'm writing a ScriptRunner custom macro that will process its body, but I'd prefer to process storage format (which is valid XML) rather than view format (which isn't). Looking at ConversionContext, there are methods to convert storage to view but (not surprisingly I guess) not the other way round.
As explained at https://docs.adaptavist.com/sr4c/latest/features/macros/custom-macros, the macro body is available in the body variable, but this appears to be view format and I don't see any way of requesting storage format. I checked whether there were any other hidden variables (such as bodyStorage) in the binding, but there don't appear to be.
Any ideas? Thanks.
UPDATE: I created a simple example that uses the "status" macro. Here is the storage format (I've inserted some line breaks to make it more readable):
<p class="auto-cursor-target"><br /></p>
<ac:structured-macro ac:name="inspect-body" ac:schema-version="1"
<ac:structured-macro ac:name="status" ac:schema-version="1"
</ac:structured-macro> <p class="auto-cursor-target"><br /></p>
inspect-body is my custom macro and it just returns the body HTML as literal text. The weird thing is that I'm seeing different view formats when previewing the macro in the macro editor:
<img class="editor-inline-macro" height="18" width="88"
...and when saving the page (again I've added some newlines in both cases):
<p talk-marker="1" talk-page-id="116228112" talk-page-version="7">
<span class="status-macro aui-lozenge conf-macro output-inline"
I guess I need to be able to process both of the above (because I want the macro logic to execute both in the editor and when saving the page) but of course the <img> tag isn't terminated, so I can't parse it as XML. I guess I'll either preprocess it to make it valid XML or else do a naive parse (I don't care about the full details of the XML; I just want some bits, e.g., the status macro text).
Does this additional information help to point to the source of the problem, if indeed it is a problem?
Also, I don't suppose it's relevant, but the SR version is 6.36.0.
Hi Atlassian Community, My name is DJ Chung, and I’m a Product Manager on the Confluence Cloud team. Today, I’m excited to share a new and improved version of Home. The new Home helps you ...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events