Discussion:
[tw] Moving all instances of specific macro into a field
(too old to reply)
David Allen
2017-05-14 22:25:19 UTC
Permalink
Raw Message
Here's what I'm wanting to do:

1. Find all tiddlers that contain a specific macro call in their main
body
2. Isolate the text of the macro call
3. Copy the macro call text into a new field
4. Replace the text of the macro call with a reference to the new field

Steps 1 and 3 seem easy enough, but I'm not sure how to approach 2 and 4.

An example of what I want to do:

*Title: Whatever*
*Tags: Whatever*
*Text:*

*<<single_image imageURL>>*

*other text in the main body*

*Fields: None*

The above should become the below:

*Title: Whatever*
*Tags: Whatever*
*Text:*

*{{!!image}}*

*other text in the main body*

*Fields:*
*image: <<single_image imageURL>>*
--
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 ***@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/9551551d-94e4-44ce-b702-966e98fb7d92%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mat
2017-05-15 06:20:00 UTC
Permalink
Raw Message
Should be doable.A good start is to check out Grand TWizard Tobias Beer's split
filter operator <http://tobibeer.github.io/tw5-plugins/#split>.

The overall strategy could perhaps be something like

make a button
with some list filter inside it to...
...get the text (the "get" filter operator) and
...split out the macrocall(s) and save them as variables
...but also save the remainder of the text which is sent into the list
filter again
and use setfield widgets for the relocation

<:-)
--
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 ***@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/1616a5f7-5eb2-4029-a9a1-0e282b79f212%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
David Allen
2017-05-16 15:53:42 UTC
Permalink
Raw Message
The problem I'm having with that (as well as the built-in splitbefore) is
in both instances, if the text contains any spaces, the block of text I
wanted isolated is surrounded in double square brackets, which I do not
want. How would I fix this?
Post by Mat
Should be doable.A good start is to check out Grand TWizard Tobias Beer's split
filter operator <http://tobibeer.github.io/tw5-plugins/#split>.
The overall strategy could perhaps be something like
make a button
with some list filter inside it to...
...get the text (the "get" filter operator) and
...split out the macrocall(s) and save them as variables
...but also save the remainder of the text which is sent into the list
filter again
and use setfield widgets for the relocation
<:-)
--
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 ***@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/b8924ae1-5045-49ea-bc2e-1d5338d05738%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Eric Shulman
2017-05-16 16:51:16 UTC
Permalink
Raw Message
Post by David Allen
The problem I'm having with that (as well as the built-in splitbefore) is
in both instances, if the text contains any spaces, the block of text I
wanted isolated is surrounded in double square brackets, which I do not
want. How would I fix this?
You can use the <$wikify> widget to "render" the filter results. Assuming
the filter results are in "somevar":

<$wikify name="somevar" text=<<somevar>>>
... your code here ...
</$wikify>

By default <$wikify> parses the content as wikitext and renders as plain
text, so as long as the content doesn't have any wiki syntax (other than
the enclosing double square brackets), the above code will just remove the
brackets around the link text, without any other effects.

Note also how I've used the *same variable name* as both the source (text)
and target (name) for the $wikify. This is just for convenience so you
don't have to change any of your code within the <$wikify>...</$wikify>
block. You can, of course, use a different target name so that the
original bracketed value can still be available, if appropriate to your
use-case.

enjoy,
-e
Eric Shulman
TiddlyTools: "Small Tools for Big Ideas" (tm)
InsideTiddlyWiki: The Missing Manuals
--
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 ***@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/b4e532af-4b60-4036-b977-17eb4e549155%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...