How to escape angle brackets inside a macro?

189 views
Skip to first unread message

talha131

unread,
Jul 5, 2018, 2:40:50 PM7/5/18
to TiddlyWiki

I have this text <<list-links "[tag[fish-shell]sort[title]]>>, that I am trying to place inside copy-to-clipboard macro.

I tried following, but it didn’t work.

<<copy-to-clipboard 
<<list-links "[tag[fish-shell]sort[title]]>>
>>

Then taking cue from “How to escape double quotes inside copy-to-clipboard macro?”, I tried following but it too didn’t work.

<<copy-to-clipboard """
<<list-links "[tag[fish-shell]sort[title]]>>
"""
>>

Finally I tried, following syntax which worked

<$macrocall $name="copy-to-clipboard" src="""
<<list-links "[tag[fish-shell]sort[title]]>>
"""/>

My question is, is it possible to use << angle brackets inside <<copy-to-clipboard >> syntax?

Jed Carty

unread,
Jul 5, 2018, 2:46:55 PM7/5/18
to TiddlyWiki
I don't think that this is possible due to how the parser works. Because there is the macro call widget that can be used to get around the problem I don't think anyone is very motivated to dig into the parser and try and fix it because fixes like that often come with enough edge case problems to cause nightmares.

And I think that it is the >> part that is specifically breaking it, this may be able to be used to get around the problem in some cases. I don't see how to use it in this one, but in the past I have been able to cheat and put the first > in one macro and the second > in another one and build a string that contained things that couldn't go into a single argument.

talha131

unread,
Jul 5, 2018, 2:48:26 PM7/5/18
to TiddlyWiki

Thank you Jed.

TonyM

unread,
Jul 5, 2018, 9:42:06 PM7/5/18
to TiddlyWiki
Talah,

Now every time I want to do this, to use << angle brackets inside <<macro>> syntax? I convert it to a macro call. 

However the copy-to-clipboard is a basic and not very sophisticated macro. You can't even change or hide the label. 

But the copy to clipboard macro is based on the message="tm-copy-to-clipboard" so I built my own macro to copy the content of the "fieldname" in the current tiddler

\define edit-fields-copy-to-clipboard(fieldname)
<$set name=field-content value={{!!$fieldname$}}>
<$button class="tc-btn-invisible" message="tm-copy-to-clipboard" param=<<field-content>> tooltip="Copy fieldname $fieldname$ contents to clipboard">
<$image width="14" source="$:/PSaT/EditFields/Clipboard.png"/>
</$button>
</
$set>
\end

And call in a tiddler or in a list that changes the current Tiddler
<<edit-fields-copy-to-clipboard fieldname>>

So you to can build a custom macro that actually works for you.

and as stated before any macro can be called using the macrocall widget eg; in this case

<$macrocall $name="edit-fields-copy-to-clipboard" fieldname="myfieldname"/>

in which it is possible to do this

<$macrocall $name="edit-fields-copy-to-clipboard" fieldname=<<mymacroorvariable>>/>

You could add tiddlername to the parameters of your macro, however I currently favour making my macros use the current tiddler and I get the calling tiddler to manage what is the current tiddler with the ListWidget or the TiddlerWidget.

Regards
Tony

talha131

unread,
Jul 7, 2018, 3:51:43 PM7/7/18
to TiddlyWiki

Thank you, Tony. That’s very helpful. I am in the process of updating my macro with the help of your example.

Meanwhile, can you please explain this part


<$image width="14" source="$:/PSaT/EditFields/Clipboard.png"/>

When I use this source, I get an empty image. My list of shadown tiddlers does not have any $:/PSaT/. I have searched the docs but couldn’t find information on how to link to builtin images in TiddlyWiki.

TonyM

unread,
Jul 7, 2018, 10:01:41 PM7/7/18
to TiddlyWiki
Talha,

Forgive me for that omission, Just find any image you load into or find already in TiddlyWiki

eg

<$image width="14" source="$:/core/images/copy-clipboard"/>

To lookup what a widget is, beginning with a <$ like the above <$image search on TiddlyWiki.com for ImageWidget and you will see what it does.

These lists will help you locate images.

!!Custom Images here

<$list filter="[is[image]]">
<$image source={{!!title}} width=48></$image>{{!!title}}<br>
</$list>

</$details>

!!Core Images here

<$list filter="[all[tiddlers+shadows]prefix[$:/core/images/]]">
{{!!text}} <$image source={{!!title}} width=48></$image>{{!!title}}<br>
</$list>

Regards
Tony

talha131

unread,
Jul 9, 2018, 9:48:58 AM7/9/18
to TiddlyWiki

Thank you Tony. These filtered lists are very helpful.

Your code has an orphan </$details> tag. Is it your own custom widget? Because I couldn’t find any DetailsWidget in the official documents.

talha131

unread,
Jul 9, 2018, 11:12:01 AM7/9/18
to TiddlyWiki

Tony, I am sure you already know this, but anyone else, beginner like me, this won’t work for core images

<$image source={{!!title}} width=48></$image>

See How to use core images with ImageWidget? for details.

The final version of code that I used is

! Custom Images here

<$list filter="[is[image]]" emptyMessage="None Found">
<$image source={{!!title}} width=48 />{{!!title}}
<br/>
</$list>

! Core Images

<$list filter="[all[tiddlers+shadows]prefix[$:/core/images/]]">

 {{!!text}} {{$:/core/images/blank}} {{!!title}} <br/>
</$list>

Mohammad

unread,
Jul 9, 2018, 1:21:04 PM7/9/18
to TiddlyWiki
Good job! Its great to share everybody his/her final solution!

How do you have syntax highlighting for TW keywords? It looks nice to have syntax highlight for TW itself (e.g $list, $reveal, ....)

/Mohammad 

talha131

unread,
Jul 9, 2018, 1:32:13 PM7/9/18
to TiddlyWiki

I use Markdown-Here addon for formatting posts.

Mohammad

unread,
Jul 9, 2018, 2:05:03 PM7/9/18
to TiddlyWiki
Thank you for sharing!

TonyM

unread,
Jul 9, 2018, 7:59:18 PM7/9/18
to TiddlyWiki
Talha,

Sorry for that oversight. I usually have the detailsWidget plugin from Thomas Elmiger on my wikis for a quick and smart looking more details view, see http://tid.li/tw5/plugins.html#DetailsWidget

However as much as I like it, a plugin for such a basic function is annoying. So I plan an alternative, or will request it in the core.

Regards
Tony

talha131

unread,
Jul 9, 2018, 8:07:50 PM7/9/18
to TiddlyWiki

Thank you Tony.

TonyM

unread,
Jul 9, 2018, 8:22:52 PM7/9/18
to TiddlyWiki
Thanks for sharing,

I am still working on my edit-fields tools but you may like this macro, work in progress, With the icon field set allows you to select the image to place in the icon (or any other field)

\define edit-fields-image-picker(actions,filter:"[all[shadows+tiddlers]is[image]] [all[shadows+tiddlers]tag[$:/tags/Image]] -[type[application/pdf]] +[!has[draft.of]sort[title]]",subfilter:"")
<div class="tc-image-chooser">
<$vars state-system=<<qualify "$:/state/editFields-image-picker">>>
<$checkbox tiddler=<<state-system>> field="text" checked="show" unchecked="hide" default="hide"> Select Image</$checkbox>
<$reveal state=<<state-system>> type="nomatch" text="hide" default="hide" tag="div"><$macrocall $name="image-picker-list" filter="""$filter$""" actions="""$actions$"""/
></$reveal>
</$vars>
</
div>
\end

Then call with a field name in $field='icon'below
<$macrocall $name='edit-fields-image-picker' actions="<$action-setfield $field='icon' $value=<<imageTitle>>/>"/>
Reply all
Reply to author
Forward
0 new messages