Thanks Eric. This is what I needed.

Now, I can go further. I have several refrences to WCAG within each tiddler 
concerned, and I'd like to store them inside a tiddler field named 
"wcag21tech" and a typical contents would be "G8 G58 G78 G173 H96 SM1 SM2 
SM6 SM7". This should be translated as a list of hyperlinks "G8", "G58", 
etc by the same rules than wcagTechUrl, but wcagTechUrl is a macro and not 
a list. I have seen that the macro filter "subfilter" can really be a "map" 
function and I would then need to write a filter in javascript to be able 
to use subfilter to generate a list of hyperlink from a list of referencess.

I don't know how to cal a macro from each member of the array that would be 
derived from my wcag21tech. It seems to be totally out of question. So 
really I need to write that javascript filter. I think this filter should 
return an array of wikitext and not an iterator function. But this is quite 
new stuff for me. So I decided to begin small with q very very simple 
filter that always return an array of a single string which is always 
"fubar". I read https://tiddlywiki.com/dev/ "Filter Operators" to start 
this. But from then on, I think I will have to be in the dev list for 
building filters, won't I?

Le lundi 21 septembre 2020 à 01:54:56 UTC+2, Eric Shulman a écrit :

> On Sunday, September 20, 2020 at 3:30:48 PM UTC-7, Jean-Pierre Rivière 
> wrote:
>>
>> I want to generate URL. The aim would be to generate something like that:
>> [[G8|https://www.w3.org/WAI/WCAG21/Techniques/general/G8]]
>> [[H96|https://www.w3.org/WAI/WCAG21/Techniques/html/H96]]
>> with G8 or H96 a input.
>>
>
> Here's one way to make your code work:
> \define wcagTechUrl(ref)
> <$set name="place01" filter="[[$ref$]prefix[G]then[general]]">
> <$set name="place02" filter="[[$ref$]prefix[H]then[html]]">
> <$set name="url" filter="[[https://www.w3.org/WAI/WCAG21/Techniques/]] 
> [<place01>] [<place02>] [[/$ref$]] +[join[]]">
> <<wcagTechUrl_makelink "$ref$">>
> </$set></$set></$set>
> \end
>
> \define wcagTechUrl_makelink(ref) [[$ref$|$(url)$]]
>
> which can be invoked like this:
> <<wcagTechUrl G8>>
>
> Note the brackets used in the filter expressions: [[...]] surrounds 
> literal text, and [<...>] surrounds variables.
> Note also the makelink() helper macro to construct the "pretty link" 
> wikitext output.
>
> You could also write the filter using "addsuffix[...]" operators instead 
> of using "join[]", like this:
> <$set name="url" filter="[[
> https://www.w3.org/WAI/WCAG21/Techniques/]addsuffix<place01>addsuffix
> <place02>addsuffix[/$ref$]]">
>
> Another alternative (and perhaps the simplest) is to skip the filter 
> syntax entirely and use macro substitution handling in the makelink() 
> helper macro to construct the URL and wikitext link syntax in one go, like 
> this:
> \define wcagTechUrl(ref)
> <$set name="place01" filter="[[$ref$]prefix[G]then[general]]">
> <$set name="place02" filter="[[$ref$]prefix[H]then[html]]">
> <<wcagTechUrl_makelink "$ref$">>
> </$set>
> </$set>
> \end
> \define wcagTechUrl_makelink(ref) [[$ref$|https://
> www.w3.org/WAI/WCAG21/Techniques/$(place01)$$(place02)$/$ref$]]
>
> enjoy,
> -e
>

-- 
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 tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/37382020-159a-4efb-99c4-bdae8c5ecf58n%40googlegroups.com.

Reply via email to