On Thursday, June 11, 2020 at 6:57:54 AM UTC-7, Stallings wrote:
>
> I'd like to turn the value of a field ("bibtex-annote") into the content 
> of multiple new tiddlers for later use/transclusion. Right now, I am able 
> to copy the entire value to a single new tiddler with this button (adapted 
> from here <https://groups.google.com/forum/#!topic/tiddlywiki/8ci-cTQl_OA>
> ):
> \define annoTags() [[$(currentTiddler)$]] Annotation
> \define annoTiddler() $(currentTiddler)$
> <$button>
> <$action-sendmessage $message="tm-new-tiddler" title="New Annotation" tags
> =<<annoTags>> text={{!!bibtex-annote}}/>
> Pull annotations
> </$button>
> This works, but obviously is incapable of parsing the value into multiple 
> tiddlers. Here's the value:
> Extracted Annotations (6/11/2020, 8:20:28 AM)"Infection-control strategies 
> focused ... into this facility." (Arons et al 2020:1){\textbar}"The median 
> ... (interquartile range, 3 to 5)." (Arons et al 2020:3){\textbar}
> Which should return two tiddlers:
> "Infection-control strategies focused ... into this facility." (Arons et 
> al 2020:1)
> "The median ... (interquartile range, 3 to 5)." (Arons et al 2020:3)
>

The $button widget can contain a $list widget that splits the existing 
"bibtex-annote" field into parts and then invokes the $action-sendmessage 
for each.  Something like this:

\define annoTags() [[$(currentTiddler)$]] Annotation

<$button>
   <$list filter="[{!!bibtex-annote}split[{\textbar}]butlast[]]" variable=
"this-annote">
      <$action-sendmessage $message="tm-new-tiddler" $param="New Annotation" 
tags=<<annoTags>> text=<<this-annote>>/>
   </$list>
   Pull annotations
</$button>

notes:
* the $list filter splits the bibtex-annote value on each occurrence of 
"{\textbar}".  note that the curly-braces in this case are literal text, 
and *NOT* a field reference syntax
* the resulting items do not include the split text (i.e., "{\textbar}" is 
automatically omitted)
* the $list includes a trailing blank item due to the final instance of 
"{\textbar}", so we use "butlast[]" to remove that blank item
* the $list uses variable="this-annote" to avoid changing the value of 
$(currentTiddler)$ (which you use in the annoTags() macro)
* the tm-new-tiddler uses $param="..." rather than title="..." to specify 
the title of the new tiddler.  This allows the action to automatically add 
a numeric suffix to the title (so that each new tiddler has a unique title)

Give it a try and see if it does as you intend.  Let me know how it goes.

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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/f6742283-a5f1-41a5-9787-6680326467dfo%40googlegroups.com.

Reply via email to