I have a custom note named Chinese containing two fields:
Hanzi (Chinese character(s))
Pinyin (Standardized Latin translation)
Sometimes, a note can contain just one Hanzi, and sometimes it could contain a full sentence with multiple hanzis.
Cards
With Chinese notes two kinds of cards are generated. One named guess-the-pinyin (this one doesn’t occur any problem and it’s not really related to my question), and another one guess-stroke-order.
The problem
The guess-stroke-order card type should only be generated for notes witch Hanzi’s field contain one and only one symbol. Because guess-stroke-order bring a Maobi grid to draw the character. It’s not designed for multiple characters fields.
The question
How to conditionally generate guess-stroke-order when Hanzi field contain one and only one character?
I think you’d need to create a second note type for one-character words.
Anki’s templates have very limited forms of conditional logic. You can test if a field is empty or non-empty. But that’s all. See: Card Generation - Anki Manual (ankiweb.net)
While it is not possible to automate the process, if you wish to edit an already existing deck, it is relatively easy (or at least doable) to accomplish this using some workaround.
Add a new field; for example, you could name it Add Stroke Order Card.
Its purpose is to create a conditional replacement that controls whether the guess-stroke-order card is generated or not.
Use the Browser + some regex to find all the notes that have only one Hanzi:
e.g., note:Chinese -"Hanzi (Chinese character(s)):re:.{2}".
Select all the search results, then use Find and Replace to fill their Add Stroke Order Card field with at least one character.
For example, you can use these settings:
Open the template editor, go to the guess-stroke-order card, than wrap the entire Front Template like this: