Using the ELSE run filter prefix

The below code is a demo of *ELSE run* ~ filter prefix. It's purpose here 
is to get a parameter and remove its surrounding single or souble quotes. 
If the parameter has not any surrounding quotes, then returns itself
Macro

\define remove-quotes(term)
<$set name="item" value=<<__term__>> >
  <$set name="noquote"
    value={{{ [<item>removeprefix["]removesuffix["]] 
[<item>removeprefix[']removesuffix[']] ~[<item>] }}}
    emptyValue="Process failed!"
  </$set>
</$set>
\end

ExamplesRemove single quotes

 copy to clipboard

><<remove-quotes "'single quotes'">>

That renders as:

single quotes

Remove double quotes

 copy to clipboard

><<remove-quotes '"double quotes"'>>

That renders as:

double quotes

Empty value

The macro will return the Process failed! if no parameter passed

 copy to clipboard

><<remove-quotes>>

That renders as:

Process failed








Question:
 Is there any better solution to do the above task? One application of this 
code is scanning a tiddler and finds occurrences of <<abbr "term">> where 
term is glossary index and you want to make a list of abbreviations at the 
bottom of your tiddler.

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/36eda584-1aee-47ef-ad96-83a60c48e1ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to