Sync with Anki - strange behaviour

I have Anki Version ⁨24.11

I have a tiddler named “chalix” which is tagged “GrLat” and contains one cloze question:

<<remembercz "20241214093211770"
	"
{chalix (χάλιξ)}: {kiezelsteen, grind}
">>

I have a tiddler named “zzzz”, tagged “intro” which only contains:
{{chalix}}

The deck filter in “$:/config/TiddlyRemember/DeckMapping”:
[tag[GrLat]then[_GrLat_]]
[tag[intro]!tag[GrLat]then[intro]]

If I sync in Anki, the cloze question in Anki appears in section “GrLat

Now I add a tiddler named “aaaa”, tagged “intro” and which only contains:
{{chalix}}

If I sync in Anki, the cloze question in Anki appears in section “intro” and not in “GrLat

How is this possible, why decides the tiddler name ‘aaaa’, ‘zzzz’ where the cloze question will finally appear?

@bertelsl Have a closer look at: Create Code-Blocks Using Backticks in Discourse Threads – It tells you how to create markdown code blocks here in the forum

The cause here is that your TiddlyRemember sync filter (evidently) includes both chalix and zzzz, and because of your transclusion, both of these tiddlers contain the cloze note you’ve created. The deck mapping filter is evaluated separately for each tiddler that gets synced. On one of the tiddlers, your first filter evaluates to _GrLat_, and on the other, your first filter returns no results and your second filter evaluates to intro. So you end up with two otherwise identical remembercz notes (including the same unique ID) getting ingested into TiddlyRemember’s sync function, one with a deck of _GrLat_ and another with a deck of intro.

TiddlyRemember’s choice of note when it gets two notes with the same ID is undefined; it will only create one Anki note, but there’s no way to control which of the two results it updates the note with; it just takes the last one in whatever order TiddlyWiki retrieves the tiddlers. In your case, evidently it picked the one with the deck of intro.

All this is as documented, but obviously it’s not what you want here. To fix the problem, you simply need to change what you’re choosing to sync so that the tiddlers that would evaluate to having the wrong deck (namely, the ones in which you’re transcluding your chalix tiddler) aren’t synced to TiddlyRemember.

You don’t give enough context about what you’re trying to achieve here in your simplified example to know for sure, but it looks like you are putting just a single remembercz call in each GrLat tiddler, each of which represents a single vocabulary word. In that case, you’d almost certainly be better off putting the value of the cloze in a field of that tiddler and then generating the TiddlyRemember notes dynamically in a different tiddler. This will also give you much more structure and flexibility, too – you’d be able to, e.g., create a table of all your vocabulary within TiddlyWiki.

There is documentation on how this would work here:
https://sobjornstad.github.io/TiddlyRemember/#Dynamically%20generating%20TiddlyRemember%20notes

It focuses on how to do it for rememberq, but the situation is very similar for cloze notes.

In your case, to achieve exactly the layout you currently have, you would:

  • Change chalix to have a field containing the cloze (we’ll call it cloze).
  • Create a VocabNote tiddler where you make the remembercz call using values from the current tiddler (e.g., {{!!cloze}}, {{!!created}}).
  • In a TiddlyRemember Vocabulary Notes tiddler, use a $list widget to transclude all tag[GrLat] tiddlers through the VocabNote tiddler.
  • Change your TiddlyRemember syncing filter to include only the TiddlyRemember Vocabulary Notes tiddler. Or, if you’re also wanting to sync other things, just make sure that this filter somehow excludes any tiddlers you’re transcluding GrLat tiddlers into; you could probably even do this dynamically using the new transcludes[] operator if you need the flexibility.
  • When you want to display the chalix cloze on the intro tiddler, transclude chalix through the VocabNote tiddler, rather than just transcluding chalix, like {{chalix||VocabNote}}.

Let me know if you have more questions!

To provide a more concrete example, I work with Greek and Latin terms that are often composed of individual root words, each carrying its own meaning. I use a structured approach to document these terms in TiddlyWiki, as shown below:

Tiddler: “Brontosaurus” - tagged: “intro”

{{brontē}} 

{{sauros}}

<<remembercz ...
	"
{Brontosaurus}: {this means ...}
">>

Tiddler: “Anteosaurus” - tagged: “intro”

{{ante}}

{{sauros }} 

<<remembercz ...
	"
{Anteosaurus}</span>: {this means ...}
">>

Tiddler: “brontē” - tagged: “GrLat”

<<remembercz ....
	"
{brontē}: {donder} 
">>

Tiddler: “sauros” - tagged: “GrLat”

<<remembercz ... 
	"
{sauros}: {hagedis}
">>

Tiddler: “anteos” - tagged: “GrLat”

<<remembercz ... 
	"
{anteos}: {tegen, in plaats van}
">>

What I expect is that:
“Brontosaurus” and “Anteosaurus” end up in Anki in section “intro”;
“brontē”, “sauros” and “anteos” end up in section “GrLat”.

But with my filter, this seems not be the case:
The deck filter in “$:/config/TiddlyRemember/DeckMapping”:

[tag[GrLat]then[_GrLat_]]
[tag[intro]!tag[GrLat]then[intro]]

This to avoid I have to enter muptiple e.g. “sauros”, and indeed the cloze question for sauros appears in multuple ‘higher level’ tiddlers, “Brontosaurus” and “Anteosaurus”, but should appear only once in Anki.

My logic (but maybe/probably its wrong), tiddler “sauros” which is tagged “GrLat” appears as a transclude in the 'higher level tiddler “Brontosaurus” and “Anteosaurus”, but because the tag “GrLat” is more close to “sauros”, … “sauros” will/needs to appear in the “GrLat” section in Anki!?

But, maybe I understand, I don’t have to transclude “sauros” (the lower levels) into the “Brontosaurus” and “Anteosaurus” the higher levels. (Altough it looks nice), …???

Q: “What do you call a blind dinosaur?”
A: “A Do-you-think-he-saurus.”

from “Jurassic Park” (the first one).

:slight_smile:

2 Likes

My logic (but maybe/probably its wrong), tiddler “sauros” which is tagged “GrLat” appears as a transclude in the 'higher level tiddler “Brontosaurus” and “Anteosaurus”, but because the tag “GrLat” is more close to “sauros”, … “sauros” will/needs to appear in the “GrLat” section in Anki!?

I think if we walk through the process step by step, you’ll see why this doesn’t work.

  1. When TiddlyRemember syncs, it first scans through all of the tiddlers that match your syncing filter (in the Anki settings). If you haven’t changed this, it will look in, to a first approximation, all non-system tiddlers in your wiki.
  2. Now, for each of these tiddlers, TiddlyRemember actually renders the tiddler – the same process that’s used when you look at the tiddlers on the screen in TiddlyWiki. It doesn’t care about the tiddler’s wikitext, it only cares about what it looks like on the screen.
  3. After rendering the tiddler, it inspects the HTML to see what TiddlyRemember notes (Q/A and clozes) are in that rendered tiddler, and adds them to a big long flat list.
  4. Once it’s looked at all the tiddlers it’s going to, it takes the list of TiddlyRemember notes it’s made and compares it to your Anki collection, and adds, updates, and deletes notes as needed to bring your collection up to date.

In your case, you are ending up with multiple nearly identical entries in this big list for each cloze, because your clozes appear in multiple tiddlers. In your example above, the TiddlyRemember note created by the remembercz call <<remembercz .... "{sauros}: {hagedis}">> is entered into this list three times, and is in a different tiddler each time:

  • Once in the tiddler sauros itself.
  • A second time in Brontosaurus, because sauros is transcluded into it.
  • A third time in Anteosaurus, because sauros is transcluded into it.

So what about your deck mapping? Well, the first time it appears in the list, your deck mapping specifies this cloze’s deck is _GrLat_, because the cloze is part of the tiddler sauros, which has the tag GrLat. But the second time it appears, your deck mapping specifies its deck is intro, because it’s part of the tiddler Brontosaurus, which has the tag intro. The third time, its deck is also intro, because it’s part of the tiddler Anteosaurus, which has the tag intro.

Because transcluded text is indistinguishable to text that’s actually within the tiddler doing the transclusion once rendered (this is the whole point of transclusion, after all!), TiddlyRemember has no way of seeing which cloze is “closer to” the tag, as you say – as far as it is concerned, all three of the tiddlers this cloze appears in are equally “original” and valid. So the way you’ve set this up, the deck this cloze should go in is ambiguous – there’s no reason TiddlyRemember should pick one or the other in particular (except the intention you have in your head, which it obviously doesn’t know!).


But, maybe I understand, I don’t have to transclude “sauros” (the lower levels) into the “Brontosaurus” and “Anteosaurus” the higher levels. (Altough it looks nice), …???

If you want to continue using the exact layout you’re currently using, with the flexibility to transclude any tiddler that might contain any cloze that you don’t want to bring into the deck of the current tiddler anywhere, you need to find some way of transcluding the tiddlers containing TiddlyRemember notes only when TiddlyRemember is syncing and rendering these tiddlers. That way, each of your clozes will only be seen by TiddlyRemember once, in the original tiddler whose wikitext it’s physically located in.

In recent versions of TiddlyRemember, a variable called tr-rendering gets set to yes during syncs. So the simplest way to do this is:

<% if [<tr-rendering>!match[yes]] %>
{{brontē}}

{{sauros}}
<% endif %>

<<remembercz ...
	"
{Brontosaurus}: {this means ...}
">>

That’s going to be awkward and error-prone to write all the time though, so I’d suggest wrapping this up in a template tiddler, which I’ll call RenderUnlessSyncing (obviously you can call it whatever you want; in practice you might want something very short since you’ll be typing it a lot):

<% if [<tr-rendering>!match[yes]] %>
<$transclude/>
<% endif %>

Then you can write your tiddler as:

{{brontē||RenderUnlessSyncing}}

{{sauros||RenderUnlessSyncing}}

<<remembercz ...
	"
{Brontosaurus}: {this means ...}
">>

…and everything will work as you want.


Because this is TiddlyWiki, I’m sure we could come up with 37 other solutions as well, some of which might be better…this is just the first one that popped into my head.

Thank you for explaining this clearly and comprehensively. It has provided valuable clarity and has been very helpful to me.
Best regards, Luc.

1 Like