Inserting a linefeed with attribute substitution?

Using the new attribute substitution feature, can I insert a carriage return / linefeed?

The following makes a button. The intent is to make a tiddler with a link that is surrounded by the formatting symbol (@@). But the linefeed disappears from the output.

Thanks!

\define actions()
<$vars lf="""
"""
>
<$action-sendmessage $message="tm-new-tiddler" title=<<journalTitle>> text=```@@.hide $(lf)$ [[$(tid)$]] $(lf)$@@```/>
</$vars>
\end

<$wikify name=tid text=<<currentTiddler>>>
<$button actions=<<actions>> >New tiddler</$button>
</$wikify>

Here’s a variant that works:

\define actions()
<$let lf="""
"""
>
<$action-sendmessage $message="tm-new-tiddler" title=<<journalTitle>> text={{{ @@.hide =[<lf>] =[[$(tid)$]] =[<lf>] @@ +[join[]] }}}/>
</$let>
\end

<$wikify name=tid text=<<currentTiddler>>>
<$button actions=<<actions>> >New tiddler</$button>
</$wikify>
1 Like

Thanks for the reply! This may be the solution I will end up using. But I am curious if there’s any way to do it with substitution, mostly for aesthetics reasons.

Thanks!

Here’s another variant that works:

\define actions()
<$let lf={{{ [charcode[10]] }}}>
<$action-sendmessage $message="tm-new-tiddler" title=<<journalTitle>>
   text={{{ [[@@.hide]] [<tid>] [[@@]] +[join<lf>] }}}/>
</$let>
\end

Actually, it doesn’t quite work. The two square brackets disappear around the link disappear, making it no longer a link. But there must be some variant that would work.

Thanks!

Adjusted to add square brackets around link:

\define actions()
<$let lf={{{ [charcode[10]] }}} lb="[[" rb="]]" tid={{{ [<lb>] [<tid>] [<rb>] +[join[]] }}}>
<$action-sendmessage $message="tm-new-tiddler" title=<<journalTitle>>
   text={{{ [[@@.hide]] [<tid>] [[@@]] +[join<lf>] }}}/>
</$let>
\end
1 Like

Thanks Eric!

The complication I forgot, was that I want an asterisk in front of the link (to start a bulleted list). Obviously I don’t want a linefeed after the bullet. I guess I could use a regular expression replace to remove the linefeed after the join. Is there anything simpler?

Also, does this mean that solutions involving white space characters (like linefeeds) won’t work with substitution? It sure would have made a more readable answer.

Thanks!

Add the asterisk when you construct the bracketed tid value, like this:

<$let lf={{{ [charcode[10]] }}} lb="[[" rb="]]" tid={{{ [[* ]] [<lb>] [<tid>] [<rb>] +[join[]] }}}>

-e

1 Like

Another approach not mentioned so far is to make use of one of the WidgetMessage: tm-edit-text-operation’s as used in Editor toolbar buttons.