Hello Thomas,

 Okay I understood it is kind of decision making using filter. Seems it is 
a very clever code!
I learned a new concept! Macro name can be wrapped in a variable (create 
aliases). Thank you Thomas!


By the way I am trying to develop a small and simple to understand extract 
macro, I call it "mextract". I use it as a recursive macro, see below:
It displays each results for learning and experimenting purpose. P3 is the 
snippet it found.


\define mextract(text start, stop)

<$set name="fulltext"
  value=<<__text__>>
>
''fulltext'': <$text text=<<fulltext>> /><br>

<$list variable="p1" filter="[<fulltext>splitbefore[$start$]]">
''p1'': <$text text=<<p1>> /><br>

<$list variable="p2" filter="[<fulltext>removeprefix<p1>]">
''p2'': <$text text=<<p2>> /><br>

<$list variable="p3" filter="[<p2>splitbefore[$stop$]removesuffix[$stop$]]">
''p3'': <span style="color:red;"><$text text=<<p3>> /></span><br>


<$macrocall $name="mextract"
  text={{{[<p2>removeprefix<p3>removeprefix[$stop$]]}}}
  start=<<__start__>>
  stop=<<__stop__>>
/>

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



Now I call it like below to find for example all words in bold face.

<$macrocall $name="mextract" 
  text={{newTest2!!text}} 
  start="''" 
  stop="''">>
/>


Where newTest2 is a sample tiddler to be processed for example to extract 
all word in bold or italic.

This is //italic// and //italic2//.

This is ''bold'' and this is ''bold2''

I am here to call it `code` and `code2`.

//Thomas//

 
You can simple test it on tiddlywiki.com

By the way I am not sure how much recursive macro is recommended in 
tiddlywiki and what is its performance effect.

-Mohammad

-- 
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 post to this group, send email to tiddlywiki@googlegroups.com.
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/c6912498-23ab-4130-b1a9-681905c7ab99%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to