Celebrating the new year coming - With and Inline list macro and more

Just though I would share a small macro I made for the common need of presenting an inline list of items, with commas and a period for the last item. list-inline macro.json (500 Bytes) I have added note for those new to TiddlyWiki to learn by example.

I though I would wish you all a Happy New year and thank you for your contributions and participation in 2022 but also make this a useful post at the same time. This community is one of the best, if not the best.

Just use the macro as follows
<<list-inline filter>>

For example tiddlywiki.com
<<list-inline "[tag[TableOfContents]]">>

Gives you

Here is the macro and it illustrates a few things;

\define list-inline(filter join:", " end:".")
<$let filter="""$filter$""">
<$list filter="[all[tiddlers]subfilter<filter>first[]] [all[tiddlers]subfilter<filter>butfirst[]addprefix[$join$]]"><$link to={{{ [<currentTiddler>removeprefix[$join$]else<currentTiddler>] }}}><<currentTiddler>></$link></$list>$end$</$let>
\end
  • Making macros that accept a filter as a parameter, this is great because the parameter(s) can be one tiddler or a list of tiddlers in addition to the above filter.
<<list-inline "HelloThere">>
<<list-inline "HelloThere [[Customise TiddlyWiki]]">>
  • It shows using the first and butfirst operators and the subfilter operator
  • And how to set default parameters than can be over written.
    • <<list-inline [tag[TableOfContents]first[5]] "&nbsp;- " " ">>
    • Notice also the use of the nbsp a “non breaking space”
  • The filter could contain " or ' because internally it uses the triple quotes """
  • Finally this design tries to show how creating a macro for a general need with flexible design can possibly help make a reusable solution for the maximum people in many ways rather than being a “one off” solution.

Feel free to share a similar "gift with the community below or in your own thread. Please try and make it as flexible as possible but keeping it simple.

Happy New year

9 Likes

Here’s an alternative using the list-links macro + CSS:

<style>
.inline-list, .inline-list * {all:unset;}
.inline-list>:not(:last-of-type):after{content:", "}
</style>

<<list-links "HelloThere [[Customise TiddlyWiki]]" class:"inline-list">>.
8 Likes

I’m using a Javascript macro to do a similar thing! But I’m just turning a tiddler with # xxx list to a single line.

Interesting approach, thanks for sharing.