Note: Most versions released in 2023 and later should work with this. Try updating if your Anki version is older.
I just got my hands on some really simple code to hide all your inactive clozes. This allows you to hide every part of text that has a cloze on it and test you on only one.
I have been searching for something like this, but almost every solution requires old, complex code and desktop-only add-ons. The solution I’ll provide here requires only a few lines of code and it works on your regular cloze note type. As the built-in feature isn’t here at, this should work the best in the meantime.
I’ll also provide a working note type that you can download at the end.
Massive thanks to Anubis Nekhet for teaching me how to do this!
Styling
Paste this in your styling section:
.cloze.cloze-inactive {
color: #BDBDBD !important;
}
This sets a grey colour for all the inactive clozes. You can replace #BDBDBD
with any colour of your choice. Just make sure the colour for active cloze is different.
Front
This is the code for front template. Add it to the end of everything.
{{#Hide All}}
<script>
inactiveClozes = document.getElementsByClassName("cloze-inactive");
for (i = 0; i<inactiveClozes.length; i++){
inactiveClozes[i].classList.add("cloze");
inactiveClozes[i].innerHTML = "[...]";
}
</script>
{{/Hide All}}
This code sets the colour and then it hides the inactive clozes with [...]
. This can be changed to other formats if you wish. So, for example if you want ...
instead you can do so by changing [...]
→ ...
part:
inactiveClozes[i].innerHTML = "[...]";
Back
Here is the code for your back template:
{{#Hide All}}
<script>
inactiveClozes = document.getElementsByClassName("cloze-inactive");
for (i = 0; i<inactiveClozes.length; i++){
inactiveClozes[i].classList.add("cloze");
}
</script>
{{/Hide All}}
Now, this one is only useful if you want the text of inactive clozes to be coloured on the back side. The templates work just fine if you decide to omit it.
Extra Fields
After you have pasted in the code, add a new field to your cloze template named “Hide All”. This basically allows you to have the Hide All feature in a regular cloze note type. If this field is empty in a note, Anki only hides the cloze you’re being tested on. If you fill in “Hide All” field, then the code is activated and Anki hides all your clozed text in every card.
If you don’t want this, just remove {{#Hide All}}
and {{\Hide All}}
from the start and end of the code.
Download a Demo
Here’s my own note type that implements this. It also comes with catapuccin+prettify anki.
Anyone looking at this when the thread is closed and you have questions, feel free to start a new post in Anki > Card Design and ping me there.