\define convertto() $(name_of_tiddler)$-converted
\define textin(tname) {{$tname$}}
\define textin2() <$macrocall $name="textin" tname="""$(name_of_tiddler)$"""/>
<$edit-text tiddler="$:/html2tw/title" rows="1" size="50" placeholder="Name of tiddler to convert" tag="input" ></$edit-text>
<$set name="name_of_tiddler" value={{$:/html2tw/title}}>
<$set name="text2convert" value=<<textin2>> >
<$button>
<$action-setfield
$tiddler=<<convertto>>
text=<<html2tw>> />
<$action-navigate $to=<<convertto>>/>
Convert Tiddler Text
</$button>
<p/>Using text from ''<<name_of_tiddler>>'' and sending to ''<<convertto>>''.
The following macro displays fine here:
<<html2tw>>
</$set>
</$set>
<$set name="text2convert" value={{HTML2TW: Incoming HTML!!text}}>
<$button>
<$action-setfield
$tiddler="HTML2TW: Converted Text"
text=<<html2tw>> />
Convert Tiddler Text via action-setfield
</$button>
</$set>
<$set name="text2convert" value=<<textin2>> >
line that does it.
Why don't you just use one macro instead of creating a macro that just calls a second macro? Make textin:
\define textin() {{$(name_of_tiddler)$}}Hi mark,
this is a typical tw5 'gotcha'
<$set name="text2convert" value=<<textin2>> >
the macro only does basic text substitution.
You need to use this pattern
<$set name="text2convert" value={{$x$}} >
and so must put your code inside a macro
\define amacro(x)
<$set name="name_of_tiddler" value=$x$>
<$set name="text2convert" value={{$x$}} >
<$button>
<$action-setfield
$tiddler=<<convertto>>
text=<<html2tw>> />
<$action-navigate $to=<<convertto>>/>
Convert Tiddler Text
<
/$button>
\end
<$macrocall $name="amacro" tname=
{{$:/html2tw/title}}
/>
all the best
BJ
\define convertto() $(name_of_tiddler)$-converted
\define amacro(x)
<$set name="name_of_tiddler" value=$x$>
<$set name="text2convert" value={{$x$}} >
<$button>
<$action-setfield
$tiddler=<<convertto>>
text=<<html2tw>> />
<$action-navigate $to=<<convertto>>/>
Convert Tiddler Text
<
/$button>
<p/>Using text from ''<<name_of_tiddler>>'' and sending to ''<<convertto>>''.
THIS IS EMPTY: <<text2convert>>
</$set>
</$set>
\end
<$edit-text tiddler="$:/html2tw/title" rows="1" size="50" placeholder="Name of tiddler to convert" tag="input" ></$edit-text>
<$macrocall $name="amacro" x="""{{$:/html2tw/title}}"""/>
<$set name="name_of_tiddler" value="$x$">
.
<$macrocall $name="amacro" x="""{{$:/html2tw/title}}"""/>
Maybe some other tweak?
<$macrocall $name="amacro" x={{$:/html2tw/title}}/>
<$set name="text2convert" value={{$x$}} >
is inside of the macro now. If there is no interpolation/transclusion inside of the macro, why does value now get properly assigned when it wasn't being properly assigned when interpreted outside the macro? It feels like it should be the other way around.
Thanks Eric, Jed, and BJ!
Mark
Hi Eric,
That seems to be the final tweak. I put the triple quotes in (not BJ) before I realized that the name/argument were mismatched. I fixed the mismatch, but should have removed the quotes.
I'm still very confused about all this. If all that a macro does is substitution, how does it help to put everything inside of the macro? For instance, the line:
<$set name="text2convert" value={{$x$}} >
I'm still very confused about all this. If all that a macro does is substitution, how does it help to put everything inside of the macro?