[tw5] Ignore "the" and "a" in dynamic list?

Hey amazing people!

TW Version: 5.2.3
Saver: Quine2
OS: iOS on iPad and iPhone

I’d like to create a dynamic list of books that ignores “the” and “a”, to keep it alphabetically tidy,
But right now I can only get it to render an alphabetical list using:

<$list filter="[has:field[book]get[book]]+[unique[]sort[]]">
<$link><<currentTiddler>><br></$link>
</$list>

I’ve tried incorporating a snippet from how to remove stop words:

[enlist<book-list>sortsub<compare-without-stopwords>]

But I can’t seem to implement it correctly…

Apologies if this seems a basic fix,
(I’m not a programmer by any means, so I’m just scraping by and trying not to bug you guys with trivial stuff if I can help it.)

Hello,

First, you should first take a look at the example at the bottom of this tiddler.

It sounds like that’s what you need.

Take a look at the actual documentation tiddler (not the static version) here:
https://tiddlywiki.com/#How%20to%20remove%20stop%20words

Edit that tiddler to see the implementation. It contains this macro definition:

\define compare-without-stopwords()
[<currentTiddler>search-replace:i:regexp[^The |A ],[]]
\end

To show a title with the “stop words” moved to the end of the title, add this macro:

\define move-stopwords()
<$text text={{{[<currentTiddler>search-replace:i:regexp[(^The |A )(.*)],[$2, $1]]}}}/>
\end

To get your book list as a variable, you can write:

<$set name="book-list" filter="[has:field[book]get[book]unique[]sort[]]">

You can then use something like this to show the list:

<$list filter="[enlist<book-list>sortsub<compare-without-stopwords>]">
   <$link><<move-stopwords>></$link><br/>
</$list>

enjoy,
-e

3 Likes