I often use a couple of “expand” macro, taken from the plugin “expand” by Ben Webber. (I edited them only very slightly) These macros allow me to hide text and show it if a term is clicked.
I saw in this topic recently “How can I get the title of the tiddler created after an excision?” some interesting ideas for creating an EditorToolbar button.
I took inspiration from there to create a button that allows me to quickly create these “expand” macros.
For those who have followed the topic the behavior is very similar, but with a simpler application.
But I only partially succeeded and I can’t figure out where I would have done something different/wrong.
The problem is in this part of the code:
\define block1() <<ex- """
\define block2() """ """TERM""">><<-pand """
\define block3() """ """
\define block4() """>>
\whitespace trim
...
...
<$wikify name=expand-identifier-wikified text={{$:/EditorToolbar/button/ex-pand/dropdown!!expand-identifier-wikified}}>
<$set name="expand-identifier-wikified" value=<<expand-id>>>
<$button>
<$action-sendmessage
$message="tm-edit-text-operation"
$param="wrap-selection"
prefix={{{ [<block1>] [<expand-id>] [<block2>] [<expand-id>] [<block3>]+[join[]] }}}
suffix={{{ [<block4>] }}}
/>
</$button>
</$set>
</$wikify>
Everything is fine except for the identifier, [<expand-id>]
,which doesn’t appear at all.
Maybe to @Sobriety or @TW_Tones my mistake will be obvious, since the code from which I took inspiration is almost copied verbatim from yours.
- Where is the error?
Whole tiddler: $ _EditorToolbar_button_ex-pand_dropdownTEST.json (3.5 KB)
P.S.
One more thing, but less important:
When I define \define block2()...
is there a way to insert a line break without using <br>
?
If I try to insert it using the return key, it stops recognizing the newline text as part of the “block2”
Just to be clear, I mean something like this:
\define block2() """ """TERM""">> Here <br> but without <br>? <<-pand """
-Sam