Dynamic content macro with ability to modify page content

Our functional requirement want to modify the look and feel of the content of the existing page when macro is used . We are thinking on the line to do this with dynamic content macros but there are 2 problems.

  1. Even if we manage to get the page content in the macro and alter it the page is still going to show it’s original. Is there in some way possible that macro just beautify the page content.

  2. How it is possible to modify a page content . I am not able to find any suitable parser for confluence content, i.e received by the API, so we can identify some location inside the document where we want to perform the modification.