Line breaks in filters

Hi,

why does <$list filter="[tag[TableOfContents]]" variable="myvariable"> produces a list starting from the first row in the tiddler
but wrapping the filter in a macro

 \define tocmacro()
 <$list filter="[tag[TableOfContents]]" variable="myvariable"> 
 <br><<myvariable>>
 </$list>
\end

then calling the macro <<tocmacro>> produces a list starting from the third row with 2 line breaks at the begiuinig , is there a way around that , or am i doing something wrong

thank you

Hi @paulgilbert2000

Your macro does what it’s supposed to do: for each tiddler tagged TableOfContents, display a line break then the title of the tiddler.

You can see that with the “Raw HTML” output mode of the preview, in the tiddler editor.

Fred

1 Like

Hi,

even without the line break
it still starts on the second row

Perhaps, Show us the wikis text before and after your lists statmen and a image off the result.

If the list widget only contains a blank line it defaults to bullets

If you place anything inside a list widget it becomes the template for each item listed. This means you need to choose if there is a line break between items.

  • commonly we use <$link/><br>.
  • depending on your formatting a blank line at the top of your lists widget content may help

<br><<myvariable>> this says do a new line then display variable. Thus each item starts with a new line. It is better to end with a new line.

1 Like

To put the solution (to eliminate extra line breaks at beginning) more directly:

\define tocmacro()
<$list filter="[tag[TableOfContents]]" variable="myvariable"> <<myvariable>><br></$list>
\end
1 Like

To allow users to use indentation for better readability we can use the \whitespace trim pragma like so

\whitespace trim

\define tocmacro()
\whitespace trim
. . .
\end
  • The first pragma is responsible for the tiddler content.
  • The second pragma is needed for the macro code
2 Likes

thanks tones ,its the screen shot above , bascially i want to wrap a list in a macro then call it , and the problem is it always renders with a line break before the list result


\define tocmacro()
<$list filter="[tag[TableOfContents]]">

</$list>
\end

<<tocmacro>>
  • This does what you want.
  • An empty line inside the list template causes the default to be used.
  • Notice we do not need to name the variable, but you can with no change.
1 Like

Just to be sure you saw this @paulgilbert2000:

Default CSS rules define a margin above the <p> but as you can see there is no line break before the <$list> result.

Fred

2 Likes

I gave an answer above, but don’t yet have the full explanation, I think there is a line break implied either in the macro or what comes before the macrocall.

This area is in part documented here “Inline Mode WikiText” ands “Block Mode WikiText” on tiddlywiki.com

Thank you for your help , and sorry for your late reply , i think i got what i wanted