Remove brackets from filter output

I have this filter: [links[]join[ ]]. This is working flawlessly except for the fact that it’s returning the output enclosed in brackets. How can I remove the brackets from the output?

Currently Output: [[eternity joy]]
Desired Output: eternity joy

Could you give us a little more context about how you’re using the filter and what you’re trying to accomplish with it — ideally with a code snippet or a sample wiki we can test? I just tested the first options that occurred to me…

{{{ [links[]join[ ]] }}}

<$text text={{{ [links[]join[ ]] }}} />

… and neither produce square brackets, so it’s difficult to diagnose the problem.

Here is the full code:

\whitespace trim
\procedure update-links-button()
<$fieldmangler>
	<$button
		tooltip="Update the links field with current links"
		aria-label="Update links field"
		class=<<tv-config-toolbar-class>>
	>
		<$set name="linksList" filter="[<currentTiddler>links[]join[ ]]">
		<$action-setfield $field="links" $value=<<linksList>> />
		</$set>
		<%if [<tv-config-toolbar-icons>match[yes]] %>
			{{$:/core/images/link}}
		<%endif%>
		<%if [<tv-config-toolbar-text>match[yes]] %>
			<span class="tc-btn-text">Update Links</span>
		<%endif%>
	</$button>
</$fieldmangler>
\end
<<update-links-button>>

I’m trying to set a field with all the links in the body of the tiddler.

Hi @switchplayer

If you want your links field to work with links to tiddlers with spaces in their title, you must use format:titlelist[] before join[ ] like this:

\whitespace trim
\procedure update-links-button()
<$fieldmangler>
	<$button
		tooltip="Update the links field with current links"
		aria-label="Update links field"
		class=<<tv-config-toolbar-class>>
	>
		<$let linksList={{{ [<currentTiddler>links[]format:titlelist[]join[ ]] }}}>
		<$action-setfield $field="links" $value=<<linksList>> />
		</$let>
		<%if [<tv-config-toolbar-icons>match[yes]] %>
			{{$:/core/images/link}}
		<%endif%>
		<%if [<tv-config-toolbar-text>match[yes]] %>
			<span class="tc-btn-text">Update Links</span>
		<%endif%>
	</$button>
</$fieldmangler>
\end
<<update-links-button>>

Note that I replaced the <$set> widget with a <$let> widget and changed the syntax accordingly.

Fred

Hey Fred, This worked great! One other question - right now I have this as a separate button that I’m clicking prior to actually saving the tiddler. Is there any way it can run when I click the Save button? I’d save a click if so.

Well, for this you could clone the original save button $:/core/ui/Buttons/save, add your code to its original code, and then disable the original save button, keeping only your clone visible in the toolbars settings (Control panel => Appearance => Toolbars => Edit Toolbar).

Anyway, I can’t help but wonder why you’re writing in a field an information that is dynamically available through a simple filter any time you need it?

Fred

I want to be able to use the Locator plugin to filter based on links IN the text field of tiddlers, and unless I’m missing something (which could definitely be the case), this seems to be the only way.