Get Tiddler information in a Macro

131 views
Skip to first unread message

Milind

unread,
Jun 7, 2019, 3:50:28 AM6/7/19
to TiddlyWiki
Hello,
          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?

Thanks,
Milind

PMario

unread,
Jun 7, 2019, 4:17:12 AM6/7/19
to tiddl...@googlegroups.com
Hi Milind,

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?

If you want to track

 - ! heading
 - [[links]]
 - [img[image-links]]

only, it should be doable, if you dig into the parse-tree.

----------------

What makes it hard is: transclusion and the list-widget. eg:

Tiddler A contains an image link like so: [img[Motovun Jack.jpg]]
Tiddler B contains {{Tiddler A}}

So if you call your macro in Tiddler B. Should it know about the link in Tiddler A??

----------

<<list-links filter:"[tag[HelloThere]]">> ... gives you 6 links.

What should happen here?

have fun!
mario



Milind

unread,
Jun 7, 2019, 10:58:52 AM6/7/19
to TiddlyWiki
Thank you very much for the reply. I don't want to follow tiddler transclusions for now, just want to keep it simple to learn more. How do I access the parse-tree?

BJ

unread,
Jun 7, 2019, 11:50:29 AM6/7/19
to TiddlyWiki
you can see how the tree is parsed in the markdown plug - a nearly identical tree is produced by the markdown lib and is then converted to a tw tree


all the best

BJ

BJ

unread,
Jun 7, 2019, 12:00:16 PM6/7/19
to TiddlyWiki
If you edit a tiddly in the prerelease there are options to see the parse tree in the preview panel:


It uses the wikify widget - see:


On Friday, June 7, 2019 at 4:58:52 PM UTC+2, Milind wrote:
Message has been deleted

Milind

unread,
Jun 7, 2019, 12:09:08 PM6/7/19
to TiddlyWiki
Is there any sample code that shows how to get to the tree from say the tiddler object?
It is quite time consuming to go through and understand the code especially if you are not a javascript programmer. I have already spent a couple of hours on this and seem to be getting nowhere. The documentation is hard to find and sometimes I cant find anything.
It would be tremendously helpful if there is a sample code that shows how to say iterate over the headings of a given tiddler or something like that.

BJ

unread,
Jun 10, 2019, 5:09:08 AM6/10/19
to TiddlyWiki
Reply all
Reply to author
Forward
0 new messages