Builds conservative Anki cloze-deletion markup for a Cloze note's Text field.
More...
Static Public Member Functions | |
| static string | Wrap (string text, int index=1, string? hint=null) |
| Wraps answer text in Anki cloze-deletion markup. | |
Builds conservative Anki cloze-deletion markup for a Cloze note's Text field.
A cloze deletion hides part of a sentence during review. Deletions sharing an index appear on one card; different positive indexes create separate cards. This helper deliberately supports the common, non-nested form only so user content cannot accidentally terminate the marker. It returns markup text and neither HTML-escapes nor sanitizes it.
Use AnkiDeck.AddClozeNote for the matching conventional note type. Advanced Anki constructs—nested clozes, template markup inside an answer, or content containing {{, ::, or }}—must be authored as trusted raw field text with the low-level AnkiDeck.AddNote API and tested in the target Anki version.
Definition at line 26 of file AnkiCloze.cs.
|
inlinestatic |
Wraps answer text in Anki cloze-deletion markup.
| text | The answer hidden while the card is shown. |
| index | The positive cloze index. Deletions with the same index appear on one card; different indexes create separate cards. |
| hint | An optional hint displayed in place of the hidden answer. |
{{c1::answer}}, or {{c1::answer::hint}} when a hint is supplied. The original answer and hint text are otherwise preserved exactly. The returned value is markup rather than HTML-escaped text. To prevent ambiguous or malformed output, answer text and hints containing the structural delimiters {{, ::, or }} are rejected. Empty answer text is rejected; an empty hint is allowed and is emitted explicitly. The index is not capped at Anki's UI conventions, but it must fit a positive int and should remain reasonably small for interoperable decks.
| ArgumentException | text is empty, or text or hint contains a cloze delimiter. |
| ArgumentNullException | text is null. |
| ArgumentOutOfRangeException | index is less than one. |
Definition at line 55 of file AnkiCloze.cs.