Get information about a tiddler in a Macro

I have been using Tiddlywiki Classic for many years now. I want to transition to tiddlywiki 5 now especially because of noteself which is what I have always wanted in Tiddlywiki. I need to import a lot of macros that I have in tiddlywiki classis. I am not a javascript programmer. I am trying to learn how to code macros in Tiddlywiki 5. I am having a very hard time finding any information about the tiddler object etc. I posted on tiddlywiki mailing list but every reply I am getting seems to assume there is some documentation somewhere which would tell me a lot about the objects. I am hoping someone here can hepp me with sample code: This is my first attempt at writing a Macro. I have exported name, params and run. The run works fine for simple stuff like just returning a piece of string. Now I am trying to elaborate the run function. I want to get all the content of the tiddler and get a list of headings, images, links in the tiddler. How can I do that? After browsing through a lot of code I figured out that this.wiki.getTiddler(this.getVariable("currentTiddler")) will get me the tiddler and this.wiki.getTiddlerText(this.getVariable("currentTiddler")) will get the text but when I call the 2nd one it seems as if this goes into a recurisve loop by trying to evaluate the macro everytimr the getTiddlerText function is called. Is there a way to get the information about the Tiddler and use it in a Macro?

You can not get the text of the current tiddler because that causes an infinite recursion problem.
You try to fetch the content of the current tiddler, but because the current tiddler text contains your macro tiddlywiki tries to get “expand” the macro which in turn tries to get the text again and again.

When doing normal tiddlywiki transclusions the core takes care of avoiding this kind of situations by showing you an error message, but in pure macros you don’t have this “help”.

What are you trying to achieve? The best solution may be a different one depending on your use-case.

Thank you for the response. I am trying to make a Table of Contents plugin. So I want to look at the headings and generate the list and hopefully direct links to them.

I’m new too so I’ll only say I know this works for a javascript macro. It shows up in the browser developer tools (I’m in Chrome) under the source tree. One can actually set breakpoints and do the same debugging and variable inspection that’s possible with standard web programming.

I’m just about to poke around in the $tw object.