Find macro application: List all macros in a wiki

78 views
Skip to first unread message

Mohammad

unread,
Mar 21, 2019, 7:37:01 AM3/21/19
to tiddl...@googlegroups.com
Referring to Find macro announcement (https://groups.google.com/d/msg/tiddlywiki/I-tJ-ITpfi4/VhrgQ2xcGgAJ)
I would like to introduce some application of this incredible macro here.

Display macros as separate block

Concept

Macros in Tiddlywiki are stored in tiddlers tagged with $:/tags/Macro and their contents are hidden. For documentation purpose it is desired to show macros in separate blocks with macro name as heading and content wrapped into <pre> tag.

Using find with delimiters begin="\define" and end="\end" can extract macros from any tiddler. When a macro is extracted a second find run on the result with start=" " and end="(" can extract the macro name.

Usage

In any tiddler contains macros, put the below script

!! Macro
<<<
<<show-macro>>
<<<

Limitation

The show-macro works based on delimiters. If macro is defined as a single line (with no \end delimiter) the macro may fail.

Install

Drag and drop the below macros into your wiki

 



Mohammad

unread,
Mar 21, 2019, 7:39:56 AM3/21/19
to tiddl...@googlegroups.com
Case II
How to list all macros in a wiki?

his example shows how the shod-macro macro can be used to display macros inside a filtered list of tiddlers.

  • Example

List all macros in first three tiddlers tagged with $:/tags/Macro

<$list filter="[tag[$:/tags/Macro]limit[3]]">
<li><$link to=<<currentTiddler>>> <$text text=<<currentTiddler>> /></$link></li>
<blockquote>
<<show-macro>>
</blockquote>
</$list>

That renders as:

 DBADGE

\define dbadge(subject,status, type:"primary")
<div class="dbadge"><span class="dbadge-subject">$subject$</span><span class="dbadge-status dbadge-$type$ ">$status$</span></div>
\end

 ALERT

\define alert(type:"primary" text:"", width:"100%", class:"")
<div class="alert alert-$type$ $class$" style="width:$width$;">
$text$
</div>
\end

 ALERT-LEFTBAR

\define alert-leftbar(type:"primary" text:"", width:"100%")
<div class="alert bg-transparent leftbar border-$type$" style="width:$width$;">
$text$
</div>
\end

 WIKITEXT-EXAMPLE

\define wikitext-example(src)
<div class="doc-example">

<$macrocall $name="copy-to-clipboard-above-right" src=<<__src__>>/>

```
$src$
```

That renders as:

$src$
\end

 WIKITEXT-EXAMPLE-WITHOUT-HTML

\define wikitext-example-without-html(src)
<div class="doc-example">

<$macrocall $name="copy-to-clipboard-above-right" src=<<__src__>>/>

```
$src$
```

That renders as:

$src$
</div>
\end
Best 
Mohammad

Mohammad

unread,
Mar 21, 2019, 8:00:29 AM3/21/19
to TiddlyWiki
Try this on tiddlywiki.com and see the interesting results!

--Mohammad
Demo:  file:///G:/TW/TW-Findmacro/Find%20macro.html#Example%2001%3A%20List%20Macros%20from%20Tiddlers

Best 
Mohammad

Birthe C

unread,
Mar 21, 2019, 8:02:52 AM3/21/19
to TiddlyWiki
Hi Mohammad,

Do you have a working link for this?


Birthe

Mohammad

unread,
Mar 21, 2019, 8:39:39 AM3/21/19
to TiddlyWiki
Hi Birthe,
 Check it here:
Sorry for incorrect link. I modify the original posts. You can check this also on Tiddlywiki.ocm

--Mohammad

Mohammad

unread,
Mar 21, 2019, 8:42:11 AM3/21/19
to TiddlyWiki
For those receive posts through email. I corrected the links as below
Best
 Mohammad

TonyM

unread,
Mar 21, 2019, 9:13:11 AM3/21/19
to TiddlyWiki
Mohammad,

nice example of using access to macros such that they are somewhat self documenting.

As suggested by me previously I think it would still be valuable to develop a convention to create a fied macro-macroname containing the syntax and descriptor of any macro in a given tiddler. We could then combine these to give a full description of any macro.

However rather than in line in wiki text an editor toolbar item with a dialogue that searches for macronames and displays the macro content with an option to past into wikitext or clipboard would realy help desiging.

I am happy to help build the editor toolbar item.

Regards
Tony

Mohammad

unread,
Mar 21, 2019, 11:36:24 AM3/21/19
to TiddlyWiki
Hi Tony
Good suggestion. Here I want to show the capability of find macro. I have started another project to create a TW resource for useful macros. I will share my idea in another thread to announce it and I would be happy to collaborate on that.
By the way, we may need more efficient search and paste then.

Many thanks for your feedback and your idea.

Best
Mohammad

@TiddlyTweeter

unread,
Mar 21, 2019, 1:25:38 PM3/21/19
to TiddlyWiki
Mohammad

I like your approach very much.

FYI---very helpful for people who are not particularly interested in coding but do need to understand basics.

It has helped me understand macros can be quite easy for basic things.

They are actually Very Good Learning Materials, as well as adding to utility.

Many thanks
Josiah

Mohammad

unread,
Mar 21, 2019, 2:55:37 PM3/21/19
to TiddlyWiki
Many thanks Josiah!
I hope I can improve this app to be more useful.

--Mohammad
Reply all
Reply to author
Forward
0 new messages