Git Product home page Git Product logo

anki_cloze_anything's Introduction

Anki Cloze Anything

Build Status Release

This project provides a template-based cloze implementation that:

  • is completely independent from Anki's Cloze Deletion,
  • does not require any modifications to Anki (via a plugin) for it to work,
  • and provides more flexibility in cloze card generation

This is achieved purely through JavaScript in the card template and a novel application of Anki's built-in (awesome) Selective Card Generation feature. The big benefit of this is that you can generate cloze cards from existing notes, for which you may already have cards. It has no dependency on Anki's Cloze note type nor any other note types, which means you don't have to migrate your cards to a new note type. It is compatible with Anki Desktop, AnkiMobile, and AnkiDroid.

Getting started is easy. You can either download the shared deck or follow the instructions for setting up the templates manually.

Features

Replicating Anki functionality with JavaScript and card templates is not the goal however. The goal is endless flexibility. You can add cloze cards to any existing note type ("cloze anything") simply by adding new fields and card templates based on the instructions found here. You can also modify the templates completely, using them simply as a guide.

With the default settings this replicates Anki's cloze functionality. However the template is highly configurable and lets you do things you can't otherwise easily do. Below is a summary of some useful features of the templates and this approach.

  • Control the visibility of other cloze deletions. Normally Anki will show the other cloze deletions besides the one currently being tested for a particular card. The approach here lets you customize this, similar to the functionality provided by Cloze (Hide All) and Cloze Overlapper.
  • Customize the cloze format. Anki replaces each clozed value with either [...] or [hint] in the case of a hint. The templates let you customize this. For example, you could use underscores and have the format be ___. Or you could always include the hint, as in ___ [hint]. Also instead of a fixed number of 3 characters you could have each non-space character replaced. So you could have ((c1::ab cdef::hint)) become __ ____ [hint].
  • Selectively reveal characters as a hint. Sometimes due to ambiguity you may need a hint at what a word starts with. The template has a simple syntax to support this. Simply surround the characters you want to keep with backticks. For example, ((c1::`a`bc `d`ef)) could be rendered as a__ d__. You can selectively reveal any part of the content, not just at the beginning. Note that you could also do a((c1::bc)) d((c1::ef)), however the backtick syntax may be more convenient.
  • Add cloze deletion to an existing note. Suppose you already have a note with fields Expression and Meaning and a card that tests you on Expression -> Meaning. Now suppose you want a version of Expression with cloze deletions. Normally with Anki you'd have to copy the text to a completely separate note based on the Cloze note type. This is a big headache to manage. Instead with the Cloze Anything approach you copy the text to an ExpressionCloze field in the same note. This makes it much easier to manage the content. You can easily find notes that don't have a cloze through a simple search in the browser.
  • Add multiple cloze deletion fields to an existing note. Suppose that you have a note type that tests you on vocabulary with fields VocabItem and Meaning. Suppose that you have added some example fields ExampleA and ExampleB to provide examples of how the vocabulary item is used. With the Cloze Anything approach you can create cloze versions for each of these examples as ExampleACloze and ExampleBCloze and render cards from each of them.

An optional plugin is also provided that automates some of the otherwise (minimal) manual work that would be required when following this approach.

Getting Started

There are two options for getting started:

  1. Download the shared deck I've already prepared for you and use the note type (and card templates) as the basis for your cards.
  2. Follow my detailed instructions on how to set up the fields and card templates. This is the best choice when you want to add cloze to an existing note type.

Installing the plugin is also recommended to make it easier for you to edit the cloze cards, but it isn't required.

How the Template Works

Similar to Anki's Cloze Templates, you need a field to contain the cloze content. Out of convention it's a good idea to have the field name end in Cloze in case you want to use the plugin later. Suppose you name it ExpressionCloze, as suggested in the instructions. Cloze content is entered in this field in a similar way as with Anki's Cloze Templates. The only difference is that instead of the format {{c1::text}} you use ((c1::text)). You then need fields to enable each of the cloze cards. So, suppose you want to support three clozes. You would add fields ExpressionCloze1, ExpressionCloze2, and ExpressionCloze3. You enter any text you want into these fields to enable the corresponding cloze card. Out of convention the plugin uses 1.

For example, suppose you want to create cloze cards for each of the words in the expression Ik heb honger. You would write the fields like so:

Ik heb honger fields

For an HTML rendering of this example, see front and back card examples.

Because each of the cloze fields has a non-empty value of 1, a card will be generated for each of c1 through c3. If you deleted the 1 from ExpressionCloze3 then a card will be generated for c1 and c2 only.

Let's dig into how this all works. The instructions referenced earlier have the following template for the first cloze card. Notice that the entire content of the front of the card is surrounded by conditional tags based on ExpressionCloze and ExpressionCloze1. This means that both fields must be non-empty for the card to be created, due to the way Anki card generation works. So if either of these fields is empty, the corresponding card isn't generated. The ommitted script simply looks at the number the value for data-card ends with and then updates the content within the cloze <div> accordingly. So if the value of data-card is ExpressionCloze2 then it knows to hide the ((c2::text)) and show the others.

{{#ExpressionCloze}}
{{#ExpressionCloze1}}
<div id="cloze" data-card="{{Card}}" data-cloze-show-before="all" data-cloze-show-after="all">
{{ExpressionCloze}}
</div>

{{Meaning}}

<script>
// .. ommitted ...
</script>

{{/ExpressionCloze1}}
{{/ExpressionCloze}}

The templates also support hints in the cloze deletions, as in Anki's system. For example, for the example below, heb would be replaced with [verb] instead of [...].

((c1::Ik)) ((c2::heb::verb)) ((c3::honger)).

For the full details on how to set up your card templates manually, see the instructions. Alternatively, you can use the shared deck as a starting point and use the instructions as reference in how to modify it to meet your needs.

Configuration

The template has several settings for controlling how the cloze deletions are rendered. See Configuration for details.

How the Plugin Works

The plugin does two things to make it easier for you to edit cloze deletions when following this approach:

  • Hooks into Anki's [...] button in the editor so that you can use it on other notes besides those based on Anki's Cloze type.
  • Synchronizes edits from the ExpressionCloze field (or similarly named field) to the other fields ExpressionCloze1, ExpressionCloze2, etc. that enable the corresponding cloze cards.

The [...] button behaves the same when used on one of the note types based on Anki's Cloze type. Otherwise however, if the field name ends in Cloze, like ExpressionCloze, then it will wrap the selected text, such as in ((c1::text)). This is the same as Anki's normal behavior with clozes except it uses parentheses instead of curly braces.

The [...] button has an additonal useful feature where if you press it while an empty field ending in Cloze has focus, it will copy the text from another field with the same name minus the Cloze suffix. For example, if you click the button while focusing on ExpressionCloze then it will copy the text from Expression.

You can also modify the cloze field without using the [...] button. The plugin monitors changes and identifies patterns like ((c1::text)). It makes the corresponding cloze fields to be either empty or contain 1 depending on the presence of cloze deletions. For example, if you fill in ExpressionCloze with ((c1::Ik)) ((c2::heb)) ((c3::honger)). then it will fill in 1 for each of ExpressionCloze1, ExpressionCloze2, and ExpressionCloze3. If you edit it to become ((c1::Ik)) ((c2::heb)) honger. then it will make ExpressionCloze3 empty.

Menu Actions

The plugin adds two actions in the browser under Edit -> Cloze Anything. Both of them operate on whatever notes are selected in the browser.

Auto-cloze Full Field

This automatically makes a cloze from an entire field. For example, suppose you have a field named ExpressionCloze and Expression. If ExpressionCloze is empty, then this action causes the content of Expression to be copied to ExpressionCloze and made into a cloze like ((c1::content)). It also updates ExpressionCloze1 to cause the cloze card to be generated. This is useful when you have a lot of notes with short content where you want to cloze the entire content. It's much more efficient to cloze these in bulk than one by one.

Note that this essentially is using cloze to make a Production card (i.e. given the meaning in your native language, produce the expression in the language you are learning). So why not just make a Production card template instead of using cloze? In some cases this may be more effective than using cloze. However there are a couple reasons why cloze could be useful:

  • Your notes may be a mixture of simple expressions where you want to have a single cloze for the entire content and more complex expressions where you want two or more clozes. With this action you can pick the simple expressions in the browser and cloze them in bulk.
  • Your notes may overall be simple expressions. But you may find that for some notes upon review they are more complex than you thought. Instead of one cloze you may want to change it to two or more. By using cloze you have the flexibility to change your mind in the future without having to migrate to a different note type.

Create Missing Cards

This basically just makes sure the Cloze field is in sync with the corresponding fields responsible for card generation. For example, if ExpressionCloze has ((c1::Ik)) ((c2::heb)) ((c3::honger)). then this would ensure ExpressionCloze1, ExpressionCloze2, and ExpressionCloze3 are each filled in with a 1. But ExpressionCloze4 would be made blank, if it exists. This action isn't generally necessary to use while using the plugin because the plugin ensures that these fields are updated as you change content. But if you do an import or if you edit notes before using the plugin, this can be used to fix up the fields to be in sync.

Pros and Cons

Anki already has built-in support for Cloze. So why use Cloze Anything?

Pros:

  • Cloze cards can be added to existing note types without any modifications other than adding new fields and card templates.
  • Compared to Anki's built-in Cloze type, you have more flexibility in how the cloze cards are rendered. You can choose how many of the other cloze values to show, instead of always showing them all. This functionality is similar to that provided by Cloze (Hide All) and Cloze Overlapper.
  • Relies on JavaScript and built-in Anki features such as Selective Card Generation. As cloze functionality is implemented in the templates no modifications to Anki via a plugin are required for it to work. This greatly reduces the chance that future Anki updates will break this approach.
  • No external JavaScript required. All necessary JavaScript exists in the templates.

Cons:

  • Relies on JavaScript, which works because Anki cards are treated like webpages. However, the Anki author notes that Javascript functionality is provided without any support or warranty. So there is a very small chance that a future Anki update could impact card rendering and require changes in the template, which would be promptly carried out by me given my dependence on this approach working.
  • Because cloze functionality is implemented in templates, rather than Anki, the same template effectively needs to be copied to each card template. Also if you make an edit to one of the cloze templates you need to copy the contents to the others as well.
  • Adding the type: prefix to enable type in the answer is not supported.

Compatibility

Anki Versions

The card templates are compatible with Anki Desktop, AnkiMobile, and AnkiDroid.

The plugin works with Anki Desktop 2.1. I have no plans to add 2.0 support.

Other Plugins

I have not yet tested interactions of the plugin with other cloze plugins such as Cloze (Hide All) and Cloze Overlapper. If you encounter a problem please file an issue and I will do my best to fix it.

The following plugins have been reported as having compatibility issues with this plugin:

Inspiration

In addition to inspiration drawn from Anki's cloze system itself, there are a couple related Anki cloze plugins that provided some inspiration for features found here. Thanks to all authors for the thought put into Anki and these plugins that have helped develop new ideas.

Plugin Releases

  • 0.1 - Initial release (2019-12-17)
  • 0.2 - Add menu actions Auto-cloze Full Field and Create Missing Cards (2019-12-29)
  • 0.4 - Update to work with Anki 2.1.49 (2021-12-08).

Template Releases

  • (2019-12-17) Initial release
  • (2019-12-24) Template now allows numbers within field names.
  • (2020-01-03) Additional configuration options. Backticks to retain characters as hints.
  • (2020-05-31) Add CSS for current cloze to highlight it on the back side of card. Change font weight for current cloze to bold. See Issue #7

License

Copyright 2019-2021 Matthew Hayes

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

anki_cloze_anything's People

Contributors

matthayes avatar rwmpelstilzchen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

anki_cloze_anything's Issues

Proper length computation for Japanese readings

Setting data-cloze-replace-same-length to true will not compute the proper length for text that contains a Japanese reading, such as 日本語[にほんご]. It should render as ... but instead it will render as .......... There should be an option to ignore the reading-related characters, including the leading space if it exists.

Make the revealed text blue and change font weight to bold

One simple change that can be done to replicate anki's built in clozes is to add font-weight:bold; to current cloze.

Another problem is when the cloze is revealed, it isn't blue. I couldn't find how to change this.
For example,

result = result.fontcolor("blue");
return result

in the expContent.replace function thinggy doesn't work, it makes every cloze blue. I assume this is because the sole purpose of that function is to strip the ((c1::)) off the text.

Is there a way to make the current cloze reveal blue?

Formatting disappears when clicking on another input field.

Steps:

  1. Select text
  2. Press the cloze button (or use the shortcut key)
  3. Click on another input field

Result:

Generated formatting disappears.

This only happens when the last editing done on the field is generated via the cloze anything addon. The formatting doesn't disappear if you, for instance, add a character before switching field or if you write the formatting yourself.

Video examples:

Same steps as above:
https://0x0.st/oa8y.webm

Same steps as above, but adding a character before clicking on another input field:
https://0x0.st/oa8t.webm

Fully manual:
https://0x0.st/oa8v.webm

Debug log
Anki 2.1.51 (cf78a555) Python 3.10.4 Qt 6.3.0 PyQt 6.3.0
Platform: Linux
Flags: frz=False ao=True sv=2
Add-ons, last update check: 2022-05-14 01:48:17


===Add-ons (active)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
AJT Browser Play Button ['182970692', 2022-04-27T15:51, 'None', '']
AnkiConnect ['2055492159', 2022-04-28T12:05, 'None', '']
Cloze Anything ['330680661', 2021-12-09T16:34, 'None', '']
Kanji Grid ['909972618', 2019-01-10T07:40, 'None', '']
Review Heatmap ['review_heatmap', 2020-04-30T22:23, 'None', '']
True Retention ['613684242', 2017-11-20T05:43, 'None', '']

===IDs of active AnkiWeb add-ons===
182970692 2055492159 330680661 613684242 909972618

===Add-ons (inactive)===
(add-on provided name [Add-on folder, installed at, version, is config changed])

Is it possible to reveal one by one?

Hi,

I was desperate to find a way to make cloze deletions that coul be revealed one by one, so I found a script and worked a bit on it in my repo. So now I have something that suits my need quite well.

But I just found out about your ambitious project that is far more mature. Your knowledge of js is incomparably better than mine. I played around with it but I can't figure out if there is a way to reveal the cloze one by one. Is it possible? An example of such behavior can be seen in the demo_gif of my repo.

I didn't post this to promote my thing or anything but you might be interested in taking a look anyway.

Have a nice day! And congrats on this addon.

Cards show full expression without deletions

Very excited to use this feature - set it up on an existing deck but none of the deletions work: cards are showing the full field.

I downloaded the sample deck today (2020-07-25) and have the same problem: all cards simply show the entire sentence without any deletions.

This occurs on desktop anki (Windows 64, v2.1.28),
AnkiDroid 2.12 (deleted PC deck and re-imported shared deck),
and AnkiWeb.

clozeAnythingNoDeletion_PC

clozeAnythingNoDeletion_web

Warning, cloze types will not work [...]

Version ⁨2.1.54 (b6a7760c)⁩
Python 3.9.10 Qt 6.3.1 PyQt 6.3.1

Using your addon (and your shared notetypes, to decrease the amount of possibilities) won't allow me to add cloze-deletions outside of the hardcoded cloze notetype.

Screenshot_20230105_202655.

The ye-olde 'You need to use the cloze-note type' will still be given as a warning, making it impossible to make a new card. I have tried it in every single one of the available fields (all 23 them, for good measure!).

Is it supposed to work this way? Unexpected (but welcome) experience with Cloze Anything.

The instructions page says at the bottom that for each subsequent card type you create (ExpressionCloze2, ExpressionCloze3 etc), you must change the template for that card by swapping in the corresponding name for what I'm calling the "cloze activation" field:

Now repeat this for the remaining cloze fields. That is, if you have field ExpressionCloze2, then create a card template named ExpressionCloze2 with the same content as ExpressionCloze1 except with {{#ExpressionCloze1}} replaced with {{#ExpressionCloze2}} and {{//ExpressionCloze1}} replaced with {{//ExpressionCloze2}}. )

But in my tests today, each card type I added picked up the next cloze automatically, without my having to make that change. Which I thought was great. I found that you can use any of the cloze activation fields in the templates and you'll still get the "correct" cloze deletion/display, meaning the one corresponding to the number at the end of the card type name. In other words, it's the card type name that determines which cloze is 'activated' on a given card, not the cloze activation field name. That's a bit confusing, but convenient if you're as sloppy as I am.

I've since figured out that the reason you should go on to match up the field name in the template to the card type name is so you can turn off card production for any given cloze (by deleting all content from that cloze's activation field). If there is (arbitrary) content in the field, the cards for that cloze will be displayed; if there is no content, they won't be.

Do I have all that right?

One more question: Does it matter where you put the js reference in the card template? I'd rather put it up at the very top of the template, and when I moved it there nothing seemed to break—it didn't seem to need to be inside the conditional wrappers.

Finally, I'm hoping I won't need to keep a separate copy of the "expression" without clozes in its own field. I find that I can display the text of ExpressionCloze minus the cloze-related extra characters simply by leaving out the conditional wrappers. Your js strips out the double parens and the cloze markers (c1:: etc.). However, this only works, I think, when the ExpressionCloze field is on the front side of the card (it also has to be in a tag with id="cloze" and a 'data-card' attribute ="{{Card}}"). If you put ExpressionCloze on the back, you get all that cloze-related junk. I'm guessing it won't be too hard to modify the code to clean up the field when it's on the back. But if you have time, I'd appreciate a hint or two about how I might go about to make those changes.

request : game changer ? my dreamed type of cloze

Hi,

After you implement the "reveal one by one" scheme, I'd like to share an idea.

What about "sub clozes" : cloze that work in the same way as usual BUT if your card contains {{c1.2:: it will create automatically a new sibling that clozes only the 1.2 part.

To illustrate why this would be useful : sometimes medstudents like I am have to remember tree like concepts, for example the decision tree when encountering a specific patient. For me, "reveal one by one" cards have been a game changer as I can now use them to do subquestions like {{c1::what do you do next ? }}{{c1:: check the pulse, what are the correct pulse values ?}}{{c1:: X to Y}}
And if I forget only a subquestion, I can actually change c1 for c2 like so : {{c1::what do you do next ? }}{{c1:: check the pulse, what are the correct pulse values ?}}{{c2:: X to Y}} and this will automatically create a new card that will make me learn the detail I missed. I can then some other day turn back the 2 into 1 and delete the empty card.

But an issue with this is that as long as there is a 2nd card, the first 1 won't hide the detail. To fix this I use the duplicate card addon but it's very tedious.

So, are you interested in implementing a way to do subcloze ?

It could take the following form :

  • if a card contains only {{c1::X}} then act natural
  • if a card contains {{c1.2::X}} then : add a sibling cloze#1.2 that will cloze only the 1.2 deletions ; when reviewing card number 1, cloze all deletions (1 and 1.2) and review them one by one

Another possibility would be :

  • if a card contains only {{c1::X}} then reveal them one by one
  • if a card contains {{c2::X}} then if the card being reviewed is cloze #1 then show everything (1 and 2), else if it's cloze #2 show only c2 deletions (reveal one by one of course)

I am quite often thinking about this but It's still not very clear what kind of system would work best. I got mixed up while writing this issue so I hope I'm making sense. At least I hope I can make it clear that there seems to be a very useful tool somewhere to be made and your js implementation is clearly the perfect framework to add this.

Have a nice day.

edit : btw, is it planned to be possible to use cloze that are inside one another for the reveal one by one feature ? Take the following example : Which muscle does X ? ((c1::the ((c1::in))ternal thingie)).

Only "expression" cards appear in review

First time trying your system. Behavior same on Ubuntu (Anki 2.1.56) and AnkiDroid (2.15.6).

After importing the sample deck, I see 12 new cards in the queue. After I click 'study now,' the first card shows (Ik heb honger). After reviewing, it goes to the first card from the next note (Ik heb dorst), and then to the first card from the next note (Hij heeft dorst). After reviewing that third card (only three cards - not twelve), the new card queue number goes from 10 to zero and it tells me I have finished the deck. On the 'decks' screen it shows all zeros from the deck. I am unable to review any of the actual cloze deletion cards.

In the card browser all of the cloze deletion cards show 'new #X', and I am able to preview each card. What on earth am I doing wrong?
Thanks

Coincidental anecdote: Dutch is actually the last deck I added to Anki.

Opportunistically generate Recall card with ExpressionCloze instead of Meaning

It seems sort of redundant to duplicate the content of ExpressionCloze into Meaning for the generation of the Recall cards when the content is the same.

Why not update the Recall template's back template to simply replace all the cloze fields if the Meaning field is empty? Or perhaps use a switch mechanism to enable it like those used in the ExpressionCloseN fields?

For me to prototype (along with other changes) was to change the Recall card to Prompt -> Card+ExpressionCloze:

  • Deleted the Expression field (since I don't find it useful for this setup yet)
  • Renamed Meaning to Prompt to preserve existing cards. For me, Prompt better captures the semantics of a front card for recall.
  • Created a simple front card with conditionally rendering Prompt.
  • Flipped the isBack check.
  • Copied the ExpressionCloseN front template into the Recall back and just set cardMatch to true, and clozeNum to 0.

Or was there some other way I was supposed to configure Cloze Anything to accomplish the same thing?

"Sticky Fields" not working with Addon

Hello,
I just updated to Anki 2.1.49, which has the "Frozen Fields"-addon built into Anki, now named "Sticky Fields".
However they don't work if I have the "Cloze Anything"-addon enabled.
Neither the shortcut nor the button itself.
Is anybody else having this problem or is there an easy way to fix it?

New option: don't reveal all on back of card

It would be useful to have an option to only reveal the current cloze being tested on the backside. For example, with this option, if a card has c1 through c5, you're viewing card 3 (i.e. testing c3), and you are revealing 1 before and 1 after, then:

  • Front side shows c2 and c4, with c3 hidden and highlighted as the part being tested, and c1 and c5 are both hidden.
  • Back side shows c2, c3 and c4, with c1 and c5 both still hidden.

Anki 23.10

Hello,

I love the addon, but it doesn't work with the newer Anki version. Do you plan on updating it?

Best regards!

New

I'm on MacOS.

Under Anki 2.1.44, the plug-in button creates the cloze "((c1::blah))" but doesn't populate the FrontCloze1 field.

Under Anki 2.1.45, the plug-in button doesn't appear in the editor.

Fortunately, the keyboard shortcut still seems to work.

Add-on not working with Anki 2.1.50 beta

I tested anki-2.1.50+beta1_43c41d76-mac-qt5-intel.dmg with the recent version of the plugin that was updated for 2.1.49. The add-on is only partially working. The cloze button does not add the surrounding ((c1::blah)). However the numeric cloze fields do get updated when tabbing out of the cloze expression field so that they stay consistent. I'll inquire in the Anki forum if there is a workaround. Perhaps the wrap method was removed.

Cloze not created, then created for wrong text

Hello Matt,

Since a recent Anki upgrade (not sure if it was 2.1.49 or the one before), the cloze button hasn't worked for me. I understand this was due to changes in the Anki editor that caused Cloze Anything to break. Despite this, I was still able to use Cmd+Shift+C to create clozes with my custom Cloze Anything template. (I have been using the Custom Keyboard Shortcuts addon.) I was accustomed to seeing some weird behavior with the numbered fields but these were easily corrected.

Today, I noticed that the keyboard shortcut is no longer working. Now, when I press Cmd-Shift-C the behavior has reverted to the default Anki "{{c1:blah}}" cloze, and it complains that I'm not using the Anki cloze template. I'm not sure what I did to cause things to break today; I did experiment with Notion 2 Anki, which added a couple of new card templates (which I later deleted), but I can't see why this would have affected Cloze Anything.

In the course of troubleshooting the problem, I'm seeing some strange behavior with Cloze Anything. Here's an example, which I'm seeing when using the Cloze Anything template from the sample deck, and with the Custom Keyboard shortcuts add-on disabled:

  1. Type "first second" into the ExpressionCloze field.
  2. Select "first" and click the cloze button. "((c1::first))" is not created (the ExpressionCloze field appears unchanged), but the ExpressionCloze1 field is populated with 1.
  3. Select "second" and click the cloze button.
  4. "((c2::second))" is not created but instead the cloze for the previous action, "((c1::first))", now appears, and ExpressionCloze2 is populated.

So the first time I click the button, the cloze doesn't seem to be created but the numbered field is populated. The second time I click it, rather that creating the cloze for what I selected, it creates a cloze for my previous action. The only thing that's working as expected is the filing in of the numbered fields.

BTW, I'm using Anki 2.1.49 and the latest version of Cloze Anything on MacOS 12.1.

Cloze not working with multiple example with numbers inside

According to documentation

Note: You can have more than one field with cloze content per note. For example, you could have fields Example1Cloze and Example2Cloze. Each can be used to generate cards.

But this regexp
/^[^\d]+(\d+)$/
Will match the first number and use it for the field.

By using

ExampleFirstCloze
ExampleFirstCloze1
ExampleFirstCloze2

and

ExampleSecondCloze
ExampleSecondCloze1
ExampleSecondCloze2

This works accordingly

Can't style backs of cards freely — please add a class to display expression fields with their cloze markup hidden

Please support putting expression fields as such, independently, on the backs of cards, so that they appear without their Cloze Anywhere markup, and showing color highlighting of the current cloze. (In other words, the way they do now when you display them using {{FrontSide}}.)

By CA markup I mean substrings such as
((c1::cloze text))

Although the Cloze Anything instructions don't explicitly say so, it seems that the only way to display the contents of an "expression field" on the back of a card, without the CA markup, is through use of the {{FrontSide}} "special field." But there are lots of situations where you might want stuff on the front of the card that you don't want on the back, or you otherwise want to change the layout and/or styling on the back. (Note also that per the manual, "FrontSide will not automatically play any audio that was on the front side of the card. If you wish to have the same audio play automatically on both the front and back of the card, you’ll need to manually include the audio fields on the back as well.")

One workaround is to maintain two separate fields for the expression, one with and one without the CA markup, and use the field without the markup on the back of the card. Two problems: you don't get color highlighting of the particular cloze you're drilling on, and there's the maintenance burden and risk of error involved in keeping the two fields in sync when you make corrections or do other updates.

The following post suggests a direction for getting rid of the markup, but the regex seems incorrect, at least for fields with more than one cloze (maybe this is better: /\({2}c\d::([^\0]+?)\){2}/g). It also doesn't color highlight the current close.
https://www.ojisanseiuchi.com/2021/04/16/extending-the-anki-cloze-anything-script-for-language-learners/

Type answers

Not being able to type the answers is a major drawback for me. It means I will not use anki_cloze_anything.
I often can't decide whether to make a standard note or a Cloze Note. Combining the two is a great solution! I enthusiastically set up my normal custom Note type to include 6 more cards and was already to convert all my custom Cloze cards when suddenly I found I couldn't type the answers. Big disappointment.
Are there any plans to add typing in the near future?

Consider selecting close field after auto-copying

From @rwmpelstilzchen:

If I remember correctly, the old behaviour was that if the cloze field was empty and you used the shortcut it would not only copy the plain field but also select the content of the cloze field. This enabled the user to hit the shortcut again and have the whole field as a cloze. IMHO it is very handy, but the new behaviour only copies the content.

Convert existing built-in cloze cards to Cloze Anything

Say one has many cloze deletion cards that use Anki’s built-in mechanism. How can they convert them to Cloze Anything while saving the state, interval, review history, etc. of the original cards? Naïve ‘Change Note Type’ (ctrl+shift+M) doesn’t seem to help.

Add-on not working with latest Anki (2.1.49)

I'm running Anki ⁨2.1.49 on MacOS. I've downloaded the shared deck and it is working fine. However, the add-on doesn't seem to be working. I don't see the [...] button when creating a note (see screenshot below). The keyboard shortcut (cmd+shift+c on MacOS) that works for Anki's native Cloze note doesn't work for Cloze Anything notes either. The shared deck is useful, but without the add-on, it is a bit hard to add new notes.

image

The shortcut Crtl + Shift + C

Hello,

i really like this addon/card type. However I have a question concerning the formatting, maybe I am just missing something.
For regular cloze deletions i mostly use the shortcut Ctrl + Shift + C to insert {{c1::}} which I think is quite convenient.
Is there a way to change your formatting to the usual formating? So I don't have to type ((c1::)) but instead can just insert {{c1::}} via the shortcut.
Or is there a reason why this is a bad idea?

Follow up question:
Is there a way to enable the shorcut Ctrl + Shift + C in your card type in the browser/editor? Because currently it is only available in the "add card"-window , if used in the browser/editor anki tells me to change the card type to "Cloze".

Thanks!

Cloze replacement should support line feeds

Currently trying to quiz myself on some code examples in a <pre> block and use cloze on multiple chunks of code.

As a workaround I currently can put in multiple cloze entries with the same number, but that gives too big of a hint on how many lines are missing from the example.

Installation via collection.media

Problem

The current installation seems very cumbersome, having to copy-paste the script to 7 different cards.

Feature request

I suggest that the add-on adds a script: $XDG_DATA_HOME/Anki2/$profile/collection.media/_anki_cloze_anything.js that implements the script. Of course, cards still need to include the script, but it's reduced to a one-liner <script src="_anki_cloze_anything.js"></script> instead of the whole script in a card template.

The least thing that can be done is to suggest this installation method in the documents, since it's pretty easy to do it anyways.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.