I tried the text widget thus:
* DEMO: <$text text="""<<demo {{!!dico}} {{!!index}}>>"""/>
* MACRO: <$text text="""<$macrocall $name=demo {{!!dico}} {{!!index}}/>"""/>
and I got:
- DEMO: <<demo {{!!dico}} {{!!index}}>>
- MACRO: <$macrocall $name=demo {{!!dico}} {{!!index}}/>
I thought that the macrocall parameter were to interpretated before the
actual calling of the widget (that's what I understood from Mark S.) and
was awaiting for an other result for the MACRO line.
- DEMO: <<demo {{!!dico}} {{!!index}}>>
- MACRO: <$macrocall $name=demo {{!!dico}} {{!!index}}/>
Le mardi 6 avril 2021 à 16:35:12 UTC+2, clutterstack a écrit :
>
> Hi,
>
> You've troubleshot it pretty well yourself, and you've run into a big
> difference between WikiText and the kind of programming you might be used
> to. To quote the docs <https://tiddlywiki.com/#Macros>, "Macros are in
> fact just parameterised variables". Things don't get evaluated everywhere
> we put them; generally they get substituted, and only at particular points
> do they get evaluated. It takes some adjustment to get used to.
>
> The way I look at it, it's not so much that "{{!!dico}}" and
> "{{!!index}}" are *not* wikified (evaluated) within the double square
> bracket. It's more that TW *does* wikify the non-linked ones to render the
> tiddler.
>
> The *text* widget is a useful way of checking whether your macro outputs
> something that TiddlyWiki will wikify into the result you want.
>
> Try
>
> <$text text=<<spaceDemo dico:{{!!dico}} index:{{!!index}}>> />
>
> to see what it really looks like when TiddlyWiki goes to wikify it for
> rendering:
>
> space demo for "{{!!index}}" in "{{!!dico}}" [[{{!!dico}}]] (not
> [[{{!!dico}}|{{!!index}}]])
>
> As you've noticed, a text reference like that doesn't work inside the
> double square brackets of the link shorthand. If you type that out into a
> tiddler, you'll get the same result as if you run the macro.
>
> The most obvious way I can think of to get the output you expect is to
> write out the link widget:
>
> \define spaceDemo2(dico index)
> space demo for "$index$" in "$dico$" <$link to=$dico$/> (not
> <$link to=$index$>$dico$</$link>)
> \end
>
> Best,
> Chris
> On Tuesday, April 6, 2021 at 9:19:36 AM UTC-4 [email protected] wrote:
>
>> I wanted to check if having space within a dictionary name or an index
>> name was a go or a no-go for tw. So I wrote a macro to check it up (BTW,
>> the answer is: no, it doesn't matter).
>>
>> OK, now for what I want to say here, the macro will only print its
>> arguments as is and as a wiki link.
>>
>>
>> \define spaceDemo(dico index)
>> !!! space demo for "$index$" in "$dico$" [[$dico$]] (not
>> [[$dico$|$index$]])
>> \end
>>
>> and now the invocation was
>>
>> <<spaceDemo dico:"mon autre dico" index:"ma citation">>
>> <<spaceDemo dico:"mon autre dico" index:"ma-citation">>
>> <<spaceDemo dico:"mon-autre-dico" index:"ma citation">>
>> <<spaceDemo dico:"mon-autre-dico" index:"ma-citation">>
>>
>> and I got what I thought I would get, like
>>
>> space demo for "ma citation" in "mon autre dico" mon autre dico (not mon
>> autre dico)
>>
>> witg tge first link pointing to "mon autre dico" and the second to "ma
>> citation".
>>
>> But then I added two fields within thi tidder calling the macro:
>> * a "dico" field containing "mon autre dico"
>> * an "index" field containing "ma citation"
>>
>> and I called the macro thus:
>>
>> <<spaceDemo dico:{{!!dico}} index:{{!!index}}>>
>>
>> and then, surprise!, I got:
>>
>> space demo for "ma citation" in "mon autre dico" {{!!dico}} (not
>> {{!!dico}})
>>
>> with the first link to the litteral "{{!dico}}" and the second to
>> "{{!!index}}".
>>
>> I would have thought the argument transmitted would have been interpreted
>> before calling the macro. And why then this differences of treatment? What
>> is the mechanism responsible of this?
>>
>> Practical interest, BTW: with" [[$arg$]]" you can see
>> how really was written the argument "arg" when the macro was called.
>>
>> Regards,
>>
>>
>>
>>
>>
>>
>>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/96b76ce0-4e59-4d29-89f3-d6a89997ca71n%40googlegroups.com.