Cherrypicker segmentation Magic...

106 views
Skip to first unread message

Jan

unread,
Aug 19, 2016, 5:56:03 PM8/19/16
to TiddlyWiki
Hej,
I am working on a way to make footnotes which can be displayed like with
Mats strechtextMacro<<ref "http://stretchtext.tiddlyspot.com/">> and are
shown in footnotes or Endnotes by a filter like in Skeeves
Footnotefilter<<ref
"http://tiddlystuff.tiddlyspot.com/#Idea%20for%20a%20footnote%20filter">>.

I tried it with Tobis ~TextExcerpts<<ref
"http://tobibeer.github.io/tb5/#Text%20Excerpts">> but I didn't get it
to work...
I think I need something like Mat built in the cherrypicker<<ref
"http://cherrypicker.tiddlyspot.com/">>. Mat has made a great piece of
work there but i do not understand how the trick is done, yet

Is it possible to build something like the pick macro which segments all
content surrounded by `<<ref"` at the beginning and `">>` at the end?.

And is it possible to automatically number these segments to get numbers
for the notes and uniqueIDs for statustiddlers?.

I prepared a demonstrationand Test of my attempt at
http://slidesnstories.tiddlyspot.com/ (press recent issues)
Could some wizard have a look on this and
http://cherrypicker.tiddlyspot.com/

Thanks so much
Jan


Mat

unread,
Aug 20, 2016, 12:01:21 PM8/20/16
to TiddlyWiki
Hi Jan. I'd love to help you but I feel I must prioritize the TWederation stuff - sorry.

FYI, I started refactoring the CherryPicker macro some time ago but hit a roadblock due to the limited possibilites to work with strings and substituting sub-strings in a controlled way, using wikitext. Hope to get back to it because I have some really cool stuff I hope to make.

If you are experimenting yourself, and it's not obvious already, the CherryPicker basically traverses through the text in a recursive way until it hits the "markers" where it cuts and then continues after the end marker. At least I think this is what it does... it was a while ago ;-)

<:-)

Jan

unread,
Aug 21, 2016, 6:18:21 PM8/21/16
to tiddl...@googlegroups.com
Hi Mat,
thanks for your reply.
I think this code could be the key to some missing features.

Hi everyone
For my purposes it would be good to be able to set different start and ending marks, I guess this should be possible.
I tried to understand and change the cherrypicker Macro (http://cherrypicker.tiddlyspot.com/#CherryPicker) replacing the $mark$ by $start$ and $end$.
I understood some things, some are beyond my knowledge.
My result crashes I think due to problems with the recursion. (What means +[first[]]?)

I made a commented version of the macro,
For those willing to help who don`t know the cherrypicker, the aim is to list the sections between $start$ and $end$.
So thanks for help
Jan





<!--
 
-------------------------1. This part filters the relevant Tiddlers, gets their Text and passes it to 2. and it creates the box with the results ---------------------------------
-->
\define xtract(start, end)
@@.cherryheading $start$...$end$@@
<div style="margin: -0px 0 0 22px;">
<$list filter="[!is[system]regexp:text[$start$]regexp:text[$end$]!prefix[Draft]!title[About]!tag[About]!regexp:text[cherrypicker ]] -[prefix[CherryPicker]] -[prefix[codeCherry]]" emptyMessage="NO" variable="tid">
      <$list variable="fulltext" emptyMessage="NOpfx"
                filter="""[<tid>get[text]]""">
         <$macrocall $name="scrubprefix" txt=<<fulltext>> start="$start$" end="$end$"/>
      </$list>
</$list>
</div>
\end
<!--
 
-------------------------2. This part chops off all before the start-mark---------------------------------
-->
\define scrubprefix(txt, start, end)
<$list variable="pfx"
         filter="[[$txt$]regexp[$start$\S]splitbefore[$start$]]" >
   @@.pfx ''pfx'':<<pfx>><br>@@
   <$list variable="txt" emptyMessage="NOtxt"
             filter="[[$txt$]removeprefix<pfx>]">@@.txt ''txt:'' """<<txt>>"""<br>@@
      <$macrocall $name="pick" txt=<<txt>> start="$start$" end="$end$"/>
   </$list>
</$list>
\end
<!--
 
-------------------------3. This macro chops off at the end-mark and creates a  section which is collected and a rest which is again passed to the scrubprefix...---------------------------------
-->
\define pick(txt, start, end)
<$list  variable="cherry" emptyMessage="NOcherry"
           filter="[[$txt$]regexp[\S$end$]splitbefore[$end$]removesuffix[$end$]]
                     [[$txt$]!regexp[$end$]splitbefore[ ]]
                     [[$txt$]!regexp[\S$end$\s]splitbefore[$end$]]
                     +[first[]]">
   <span class="cherrybullet" tooltip=<<tid>>>
      <$link to=<<tid>>>{{cherrybullet.png}}</$link>
   </span><<cherry>> <br>
   <$list  variable="rest" emptyMessage="NO3"
           filter="[[$txt$]removeprefix<cherry>removeprefix[$end$ ]]
                     [[$txt$]removeprefix<cherry>] +[first[]]">
   @@.rest ''rest'':<<rest>><br>@@
      <$list filter="[<rest>regexp[$start$]]">
         <$macrocall $name="scrubprefix" txt=<<rest>> start="$start$" end="$end$"/>
      </$list>
   </$list>
</$list>
\end
--
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+...@googlegroups.com.
To post to this group, send email to tiddl...@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/4fde9dd9-7dcf-451f-ad26-713b9afbcb0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages