Wow, Thanks, Eric!
For book references, it works straightaway! For more general use, this part
would need tweaking:
removeprefix[@book
The "book" part is actually important in the bibtex system, since it
belongs in the type-field.
Of course, filling in the type field manually isn't any trouble, but the
current bit of code seems to fail if the input has something else (like
@article) in that initial position.
Looking forward to spending more time following up on all the posts here.
-Springer
On Saturday, December 12, 2020 at 3:52:13 AM UTC-5 Eric Shulman wrote:
> On Friday, December 11, 2020 at 4:45:33 PM UTC-8 springer wrote:
>
>> drag and drop the contents of a field-parsable string (onto a special
>> bibtex or json drop area if need be) and have tiddlywiki parse directly,
>> populating fields if field patterns are present?
>>
>
> Try this:
> \define dropbibtex()
> <$wikify name="source" text=<<actionTiddler>>>
> <$set name="source"
> filter="[<source>removeprefix[@book{]removesuffix[}]split[,]rest[]join[,]]"
> select=0>
> <$list filter="[<source>split[}]first[]trim[]removeprefix[title={]]"
> variable="title">
> <$list filter="[<source>split[}]]" variable="item">
> <$vars f={{{ [<item>split[={]first[]trim[,]trim[]] }}} v={{{
> [<item>split[={]rest[]trim[,]trim[]] }}}>
> <$action-setfield $tiddler=<<title>> $field=<<f>> $value=<<v>> />
> </$vars>
> </$list>
> </$list>
> </$set>
> </$wikify>
> \end
> <$droppable actions=<<dropbibtex>>>
> <$button style="width:10em;height:10em;">drop bibtex here</$button>
> </$droppable>
>
> Notes:
> * $wikify converts the dropped content into plain text, removing any
> surrounding HTML syntax
> * $set removes the leading "@book{", trailing "}" and first value (e.g.,
> "crary2016inside")
> * first $list extracts the target tiddler title value from title="..."
> * second $list extracts each named item (e.g., author={Crary, Alice)
> * $vars gets the fieldname (everything before the "={") and fieldvalue
> (everything after the "={") from the item
> * $action-setfield creates each field and value in the target tiddler
>
> 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/cc5e8615-6237-4608-b463-138f8834a80dn%40googlegroups.com.