Out of my depth with filters and stuff.

121 views
Skip to first unread message

Stephen Wilson

unread,
May 2, 2017, 7:22:05 AM5/2/17
to tiddl...@googlegroups.com
Hello Helpful People!

Following on from this thread here and Sara kindly putting her work up on tiddlyspot here: http://foxridgegarden.tiddlyspot.com/
I've finally carved out a little time to see if I can steal the core filters and apply it to my own equation heavy tiddlyspot here: stephenteacher.tiddlyspot.com/

Rather than go in all guns blazing I have started a small test wiki here http://stephenteachertests.tiddlyspot.com/

All is mostly well and things working as they should, however...

Acceleration appears to be a problem.  When I set the variable to 'a' it appears in all equations regardless of whether acceleration is in the equation or not.  If I change it to a 'b' all is fine and it only appears in the proper place.

The code from the template is:
\define varPattern()
$
(var)$
\end

{{!!equation}}

<table>
<tr><th>Variable</th><th>Description</th><th>Unit</th></tr>
<$set name="eq" value={{!!equation}}>
<$list filter="[tag[Variable]sort[title]]" variable="varTiddler">
<$set name="var" filter="[<varTiddler>get[variable]]">
<$set name="unit" filter="[<varTiddler>get[unit]]">
<$list filter="[tag[Equation]field:equation<eq>regexp:equation<varPattern>]">
<$tiddler tiddler=<<varTiddler>>>
<tr><th>
<$transclude field="variablelatex"/>
</th><th><$link><$transclude field="title"/></$link></th><th><$transclude field="unitlatex"/></th></tr>
</$tiddler>
</
$list>
</$set>
</
$set>
</$list>
</
$set>
</table>

All other templates and related can be found at http://stephenteachertests.tiddlyspot.com/


Mark S.

unread,
May 2, 2017, 11:22:56 AM5/2/17
to TiddlyWiki
Since you're looking for the letter 'a' in field that always contains the word 'latex' there's bound to be something off.

If I may suggest a simpler approach. Include a list field, say 'vars' that lists the variables associated with an equation. For acceleration, we would have

[[Inital Velocity]] [[Final Velocity]] Time

Then this simpler code would do what you want (hopefully):

{{!!equation}}

<table>
<tr><th>Variable</th><th>Description</th><th>Unit</th></tr>
<$list filter="[list[!!vars]sort[title]]" >

<tr><th>
<$transclude field="variablelatex"/>
</th><th><$link><$transclude field="title"/></$link></th><th><$transclude field="unitlatex"/></th></tr>
</$list>
</
table>

It worked on Acceleration. But you don't have the variable tiddlers for Enthalpy defined so I couldn't test that.

Good luck!

Stephen Wilson

unread,
May 3, 2017, 6:15:30 AM5/3/17
to TiddlyWiki
You're a super star.
Saves me having to learn regex which I'm guessing is where the original problem lay.
That works a treat.

Thank you.

Stephen
Message has been deleted

Stephen Wilson

unread,
May 3, 2017, 8:12:00 AM5/3/17
to TiddlyWiki
Extension Question:

template variable searches the equation field of tiddlers tagged equation and then returns values of fields which contain the variable of the tidler in which the template is called.

Can this be simplified using the new and shiny vars field?

I'm just trying to head off situations in which this filter will cause problems where the same letter is used for different values, e.g h for height and h for specific enthalpy.

Stephen

\define makePattern()
^<.*?(?:=).*?(?:=).*?(?:\b$(var)$\b)
\end

{{!!description}}

Variable: {{!!variablelatex}}

Unit: {{!!unitlatex}}

<$set name="var" value={{!!variable}}>
<$set name="varpattern" value=<<makePattern>>>
<$list filter="[tag[Equation]regexp:equation<varpattern>limit[1]]">
<h2>Used in Equations</h2>
</
$list>
</$set>
</
$set>
<$set name="var" value={{!!variable}}>
<$set name="varpattern" value=<<makePattern>>>
<$list filter="[tag[Equation]regexp:equation<varpattern>]">

<$link><$transclude field="title"/></$link>
<$transclude field="equation"/>
</$list>
</
$set>
</$set>


Mark S.

unread,
May 3, 2017, 11:10:12 AM5/3/17
to TiddlyWiki
This seems to do it:

---

{{!!description}}

Variable: {{!!variablelatex}}

Unit: {{!!unitlatex}}

<$list filter="[title<currentTiddler>listed[vars]tag[Equation]] -[title<currentTiddler>] +[limit[1]]">

<h2>Used in Equations</h2>
</
$list>

<$list filter="[title<currentTiddler>listed[vars]tag[Equation]] -[title<currentTiddler>]">

<$link><$transclude field="title"/></$link>
<$transclude field="equation"/>
</$list>


I had to look up Skoda. I like they have a whole page for cyclists.

HTH
Mark

Stephen Wilson

unread,
May 3, 2017, 11:49:28 AM5/3/17
to TiddlyWiki
Thank you very much.  Works like a charm.

Skoda used to have a reputation for building bad cars$ before they were taken over by VW.  Better than Lada's but not by much.
Typical joke:
Q: Why do Skodas have rear heated windows?
A: So you can warm your hands while you push them.

Though to be fair mine never gave me any grief.

Stephen
Reply all
Reply to author
Forward
0 new messages