How to feed text containing widgets to the copy-to-clipboard macro so that it copies the wikified text?

Hi tiddlywikians,

I’m trying to do the following:

  • I have some plain text that contains also some <$text text={{{ [[some filter]] }}}/> widgets
  • I’m showing that text in a tiddler, and it shows fine (visually)
  • I’m trying to wikify the text using the wikify widget and feeding the wikified result to the copy-to-clipboard macro
  • The copied text contains the “<$text text={{{ [[some filter]] }}}/>” string and seems not to be wikified

How would you solve that?
An example text would look like the following:

"""

Hello,

We're currently doing something with <$text text={{{ [{$:/temp/name}!match[]] ~[[Name]] }}}/>

Could you please confirm?

"""

Thanks for your help,

Simon

1 Like

Try something like this:

<$vars txt="""

Hello,

We're currently doing something with <$text text={{{ [{$:/temp/name}!match[]] ~[[Name]] }}}/>

Could you please confirm?

""">
<$wikify name="cliptxt" output="formattedtext" text=<<txt>>>
<$macrocall $name="copy-to-clipboard-above-right" src=<<cliptxt>>/>
<div style="white-space:pre;"><<txt>></div>
</$wikify>
1 Like

Thank you @EricShulman ,

I forgot to mention that the triple quotes should be part of the text because the text contains also constructs like:

"""

Hello

***

more Text

***

more Text

"""

… and *** should not be wikified

Could you not simply use the set ?

<$set name=some-filter filter="[{$:/temp/name}!match[]] ~[[Name]]">

<$macrocall $name="copy-to-clipboard" src=<<some-filter>> />

</$set>

Personally I use the WidgetMessage: tm-copy-to-clipboard in a button as a personal preference.

Ok now here my solution:

  • I created a copy-to-clipboard-decodeuricomponent macro:
\define copy-to-clipboard-decodeuricomponent(src,class:"tc-btn-invisible",style)
<$button class=<<__class__>> style=<<__style__>> message="tm-copy-to-clipboard" param={{{ [<__src__>decodeuricomponent[]] }}} tooltip={{$:/language/Buttons/CopyToClipboard/Hint}}>
{{$:/core/images/copy-clipboard}} <$text text={{$:/language/Buttons/CopyToClipboard/Caption}}/>
</$button>
\end
  • I omitted the triple quotes in the text and fed the wikify widget like this:
<$wikify name="txt" text={{{ [<get-text>encodeuricomponent[]] }}}>

<$macrocall $name="copy-to-clipboard-decodeuricomponent" src=<<txt>>/>

</$wikify>

That’s it and it works fine for my purposes
Thanks @EricShulman and @TW_Tones for your help!

Best wishes,
Simon

Nope. It doesn’t -.-
I’m still looking for a solution :slight_smile:

1 Like