How can I write a Confluence macro that reads another page and displays some part of it?
Are you trying to write an extended version of the excerpt/excerpt-include macro? If so, have you had a look at the source of that in Confluence?
Just exploring some possibilities, for my own learning. Where do I get source for other macros?
Some in the marketplace are open source, there are some example macros in the developer documentation and the excerpt macros code is in the source code you can download if you have a commercial licence for Confluence.
You can create some Java plugin, where with “PageManager” you can get pages from Confluence. Page instance have methods “getBodyAsString” and “setBodyAsString” and the body as String you can parse.
This is info where you can start: