[solved] What is wrong here please

65 views
Skip to first unread message

TW Tones

unread,
Sep 21, 2020, 10:47:31 PM9/21/20
to tiddl...@googlegroups.com
Folks,

I am building a macro "?" to locate and display information on defined macros.

However I cant get the basic operation to work, pasting this in a tiddler on tiddlywiki will show these unwanted ]"> ]"> ]"> ]"> ]"> ]"> </$list> after the two top level lists.

I cant work out why, I would be grateful for a second or more eyes.

\define macro-definition(macroname) \define $macroname$(
\define ?(macroname:"?")
<$wikify name=macro-definition text="""<<macro-definition $macroname$>>""">
searching for: <<macro-definition>>.<br>
<$list filter="""[[$macroname$]match[?]]""">
   Macro to display more about a given macro, `<<? macroname>>`
</$list>

<$list filter="[[$macroname$]!match[?]] variable=nul>
searching for: <<macro-definition>><br>
   <$list filter="[all[shadows+tiddlers]search:text:literal<macro-definition>]">

   </$list>
</$list>
</$wikify>
\end

<<?>><hr>
<<? tag>>

Regards
Tones

Eric Shulman

unread,
Sep 21, 2020, 11:32:24 PM9/21/20
to TiddlyWiki
You've left off a close quote in the 2nd $list filter!

Here's my cleaned up revision of your code.  Note there's no need for $wikify.
\define ?(macroname:"?")
searching
for: \define $macroname$<br>

<$list filter="[[$macroname$]match[?]]">
   
Macro to display more about a given macro, ``<<? macroname>>``
<
/$list>

<$list filter="[[$macroname$]!match[?]]">
   <$list filter="[all[shadows+tiddlers]search:text:literal[\define $macroname$]]">

   </
$list>
</$list>
\end

With the above code, and a test case of "<<? tag>>", I get the following results at http://tiddlywiki.com...

searching for: \define tag
$:/core/ui/EditTemplate/tags
$:/Manager/ItemSidebar/Tags
$:/core/macros/tag-picker
$:/core/macros/tag
$:/core
$:/editions/tw5.com/macro-examples/tags-of-current-tiddler

-e

TW Tones

unread,
Sep 22, 2020, 4:22:56 AM9/22/20
to TiddlyWiki
Eric et al.

Thanks for that; Amazing no matter how long I looked I did not see it.

I went for the wikify because I wrongly though I could not add "(" in the search string. But it works, thanks again.
  • "[all[shadows+tiddlers]search:text:literal[\define $macroname$(]]" I added the ( and now the result is only

So now this get's the tiddler(s) I am after with;
  • <$list filter="[all[shadows+tiddlers]search:text:literal[\define $macroname$(]] -[[$:/core]]">
Do you think it an ok assumption for the next character to be "(" ?

Now I share back the result;
\define ?(macroname:"?")
<$list filter="""[[$macroname$]match[?]]""">
   Macro to display more about a given macro, `<<? macroname>>`
</$list>
<$list filter="""[[$macroname$]!match[?]]""" variable=nul>
   <$list filter="[all[shadows+tiddlers]search:text:literal[\define $macroname$(]] -[[$:/core]]">
        Macro '$macroname$' defined in <$link/> 
        <$list filter="[all[current]get[text]splitregexp[\n]prefix[\define $macroname$(]removeprefix[\define ]]">
             <$text text=<<currentTiddler>>/>
        </$list> with 
        <$list filter="[all[current]enlist{!!tags}]">{{||$:/core/ui/TagTemplate}}</$list><br>
   </$list>
</$list>
\end

<<?>><hr>
<<? tag>><hr>
<<? tag-pill-body>>

What do you, or others think?
  • It also exposes parameters in the definition
  • Is it worthy of inclusion in the standard distribution (one day)?
  • Shows how parameter defaults are also exposed eg tree macro
Other possibilities
  • Optionally return the full definition, needs to end with the next \define or \end but what if single line last macro?
  • Return the tiddlers description is available and perhaps some hidden documentation inside <!-- comments -->
    • eg lines beginning with macro name
    • Or look up a data tiddler for core macros with additional notes.
Thanks again Eric.

Regards
Tones
Reply all
Reply to author
Forward
0 new messages