Escaping double quotes in search string that is part of a filter

346 views
Skip to first unread message

Hubert

unread,
Jun 21, 2018, 7:45:34 AM6/21/18
to TiddlyWiki
Hello,

I have an edit-text box that, when typed into, populates the note field of a $:/search tiddler.

That value is then part of a list filter. It works great except when I type double quotes (") in the edit-text box -- that obviously breaks the list filter syntax by introducing the extra quote(s).

Is there a way to escape double quotes for search or ignore (trim) them at some stage? I've already tried experimenting with pragmas but this did not have any effect (perhaps the syntax is wrong):

\rules except "
\rules except "

Here's my code (I've skipped the edit-text part because that's irrelevant):

<$set name=searchterm value={{$:/search!!note}}>

<$list filter="[tag[item]search:title[$(searchterm)$]]">
<
<currentTiddler>>
<br>
</$list>

</$set>

As an example, this is what the list filter 'sees' when the string "test" is typed into the edit-text box -- a case of nested double quotes is a recipe for disaster ;)

<$list filter="[tag[item]search:title["test"]]">

Thank you in advance for your suggestions!

Best regards,
Hubert


Mark S.

unread,
Jun 21, 2018, 11:00:13 AM6/21/18
to TiddlyWiki
This version seems to work:

<$list filter="""[search:title{$:/search!!note}]""">
<
<currentTiddler>>
<br>
</$list>

-- Mark

Hubert

unread,
Jun 21, 2018, 11:23:10 AM6/21/18
to TiddlyWiki
Mark, thank you very much!! It works brilliantly.

I wasn't aware of this syntax. It's so simple and seems powerful. There's always something new to learn thanks to this amazing community.

Thanks again!

Best regards,
Hubert
Reply all
Reply to author
Forward
0 new messages