>
> Hi Mario,
>>  I got your point. Thank you. So, that is why my code breaks in doing 
>> that.
>>
>> See below macro
>>
>> \define snr(source, searchValue, replaceValue)
>> \whitespace trim
>> <$vars 
>>  src  =<<__source__>>
>>  sval =<<__searchValue__>>
>>  rval =<<__replaceValue__>>
>> >
>> <$list filter="[<src>search<sval>]" emptyMessage="""<$text text=<<src>> 
>> />"""  >
>> <$list variable="p1" filter="[<src>splitbefore<sval>]">
>> <$list variable="p2" filter="[<src>removeprefix<p1>]">
>> <$list variable="p3" filter="[<p1>removesuffix<sval>addsuffix<rval>]">
>> <$text text=<<p3>>/>
>> </$list>
>> <$macrocall $name="snr"
>> source=<<p2>>
>> searchValue=<<sval>>
>> replaceValue=<<rval>>
>> />
>> </$list>
>> </$list>
>> </$list>
>> </$vars>
>> \end
>>
>>
>> This simple code can do find and replace and it can simple change the 
>> mario to MARIO when you work with one paragraph but as soon as you feed it 
>> a whole tiddler contains several paragraph, it fails. If I can keep the 
>> whitespace and linebreaks, it will work.
>>
>> --Mohammad
>>
>
>
> Some errors to fix:
>
> \define snr(source:"", searchValue:"", replaceValue:"")
> \whitespace trim
> <$vars 
>  src  =<<__source__>>
>  sval =<<__searchValue__>>
>  rval =<<__replaceValue__>>
> >
> <$list filter="[<src>search<sval>]" emptyMessage="""<$text text=<<src>> />""" 
>  >
> <$list variable="p1" filter="[<src>splitbefore<sval>]">
> <$list variable="p2" filter="[<src>removeprefix<p1>]">
> <$list variable="p3" filter="[<p1>removesuffix<sval>addsuffix<rval>]">
>
> <$text text=<<p3>>/>
>
> <$macrocall $name="snr"
> source=<<p2>>
> searchValue=<<sval>>
> replaceValue=<<rval>>
> />
>
> </$list>
>
> </$list>
> </$list>
> </$list>
> </$vars>
>
> \end 
>
> ... you get endless loops if you close the list before the macrocall!
>
> you should also prevent from empty attributes with source:"" etc. ...
>
> using this, try the following on tiddlywiki.com:
>
>
> <$wikify name="hellothere" text="""<$view tiddler="HelloThere" 
> mode="block" format="text"/>""">
>
> <$wikify name="result" text="""<$macrocall $name="snr" 
> source=<<hellothere>> searchValue="TiddlyWiki" 
> replaceValue="ikiWylddiT"/>""">
>
> <<result>>
>
> </$wikify>
>
> </$wikify> 
>


the p3 filter needs an emptyMessage and it fully works on tiddlywiki.com

<$list variable="p3" filter="[<p1>removesuffix<sval>addsuffix<rval>]" 
emptyMessage="""<$text text=<<src>>/>"""> 

-- 
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/5b23a86f-f687-4bfd-99be-41c1375cacd5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to