Yep, that is correct. Mohammad
On Sunday, February 24, 2019 at 12:09:10 AM UTC+3:30, BurningTreeC wrote: > > 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/0dd44bdb-5d0a-406e-82df-588c2f6bf2c2%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

