Transformer chain in Confluence

I am trying to use the transformer chain in Confluence. I implemented the Transformer interface and added this to the plugin descriptor:

<transformer key="storage-to-view-transformer" name="..." 
 class="nl.avisi.transformer.StorageToViewTransformer" chain="storageToView" weight="1"/>

I am trying to understand when the transform method is called and how to interpret the passed arguments.
What I eventually want to do is to be able to change the page content on the final pass (when all the macros have been expanded). I’m having trouble to detect that final call to transform. When does it get called for a macro on the page, or for the pagetree and how to detect that.

Any help is greatly appreciated.

If you want your class to be the last one to touch the page contents, you will need to set “weight” to a large value.

There is no difference in behavior between 1 and 100. Do I need to go higher?

I think a weight of 100 will put your transformer after any Confluence transformers. App transformers is a different story, there’s probably no way to get a good overview of what weights apps use.

Do you have any pointers on how to detect what triggers a call to transform? Is it a macro / page tree / the pages final round, that kind of questions. There’s no docs really.

Well, anytime Confluence converts from storage format to view format. Sorry, I don’t have an overview of which places exactly that happens.

I will have to figure out how to filter out all the calls to transform that I’m not interested in and pick just the one, the last one I guess, that is important. This is going to be an interesting challenge, I see pages that trigger 400 calls to transform and that’s a problem.

Thanks for your help, really appreciated!