What is the proper way to wrap a piece of text in tiddlers so I can pull it when using the $list widget? I’m looking for something “inline”, so not using other tiddlers/fields and then transcluding them
There are editor toolbar buttons that do this already, making use of the WidgetMessage: tm-edit-text-operation some discussions have also occurred in “Discourse” in relation to handling selection outside the editor.
In the editorToolbar
- Have a look at customising the stamp tools
- See How to create dynamic editor toolbar buttons which makes use of WidgetMessage: tm-edit-text-operation
Now to get it into the list widget use your selection to either set a variable, field or tiddler to the selected value. One example may be a macro <$macrocall $name=mylist selection=<<selection>>/>
in which you use “$selection$
” “$(selection)$
” or <<__selection__>>
in your list widget/filter.
Outside the editor toolbar see this thread Can we access the ‘selection’ in the WidgetMessage: tm-edit-text-operation
I’m a bit confused, and maybe I didn’t explain myself well. I want something like the following:
- Tiddler A has a lot of text, but somewhere, the text ‘foo in A’ is identified in some way (wrapped in a macro, widget, etc.)
- Tiddler B is similar, with text ‘bar in B’
- Tiddler L uses the list widget to create a table which has in the first row: first cell ‘A’, second cell ‘foo in A’, second row: ‘B’, ‘bar in B’
To do what you ask seems to need a way to parse the tiddler to find this specific reference. The simplest way is for a link to exist eg [[A]] or [[foo in A]] [[B]] or [[bar in B]] because we can always find links even to tiddlers that do not exist.
I know you are confused, but so am I.
Could I suggest you return to, and tell us, what you are trying to achieve, rather than ask for “a particular way, to do a specific thing”, which itself sounds a little odd.
Or to look at it another way, when you ask
- This is a very broad requirement, and could be somewhat challenging, although the relink plugin can do something similar.
- I don’t think many people have asked this kind of question because there are other ways to get similar outcomes (which are still not clear to me), without needing what you ask.
Hi @Ittayd
You could use “custom tags” html5 feature (search “semantic html” in you favorite search engine) to wrap the text inline, something along the lines of:
... blah blah blah <ittay>my text</ittay> blah blah blah ...
These new pseudo-tags would not be rendered by tiddlywiki, so my text
would appear as normal text.
The problem would then be to parse your tiddler text
field to extract the marked text. You want it in a <$list>
so the parsing should occur in a filter. I think the best suited filter operators for this are splitregexp
, butfirst
and butlast
. There are some code examples here in talk.tiddlywiki.org that should help you with this.
Good luck!
Fred
Here is a code snippet that seems to work:
\define source-tiddler() My tiddler with marked text
\define markin() <ittay>
\define markout() </ittay>
{{{ [<source-tiddler>get[text]splitregexp:mi<markin>butfirst[1]] :map[splitregexp:mi<markout>butlast[1]] }}}
And the example marked tiddler (“My tiddler with marked text”):
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, <ittay>dignissim sit amet</ittay>, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam. Maecenas ligula massa, varius a, semper congue, euismod non, mi. <ittay>Proin porttitor</ittay>, orci nec nonummy molestie, enim est eleifend mi, non fermentum diam nisl sit amet erat. Duis semper.
Duis arcu massa, <ittay>scelerisque vitae</ittay>, consequat in, pretium a, enim. Pellentesque congue. Ut in risus volutpat libero pharetra tempor. Cras vestibulum bibendum augue. Praesent egestas leo in pede. Praesent blandit odio eu enim. Pellentesque sed dui ut augue blandit sodales. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam nibh. Mauris ac mauris sed pede pellentesque fermentum. Maecenas adipiscing ante non diam sodales hendrerit.
Fred