AnkiIO 1.0.2
Build, validate, import, and export Anki-compatible decks from .NET
Loading...
Searching...
No Matches
AnkiIO.AnkiNoteTypes Class Reference

Creates fresh conventional Basic, reversed, and Cloze definitions for callers that need direct control. More...

Static Public Member Functions

static AnkiNoteType CreateBasic ()
 Creates a conventional Basic definition that generates one front-to-back card.
static AnkiNoteType CreateBasicAndReversed ()
 Creates a conventional Basic (and reversed) definition that generates two study directions.
static AnkiNoteType CreateCloze ()
 Creates a conventional Cloze definition with Text and Extra fields.

Detailed Description

Creates fresh conventional Basic, reversed, and Cloze definitions for callers that need direct control.

These factories mirror familiar Anki note types while avoiding a dependency on definitions installed in a user's profile. Every call returns a different, initially mutable AnkiNoteType with a new ID. Configure its CSS or add fields before creating the first note, then reuse that same instance for every note with the same schema.

For ordinary deck creation, prefer AnkiDeck.AddBasicNote, AnkiDeck.AddBasicAndReversedNote, or AnkiDeck.AddClozeNote. Those helpers reuse one matching definition across the complete deck hierarchy. Repeatedly calling these factories yourself without reusing the result can create several note types with the same visible name but different IDs.

type.Css += ".card { max-width: 42rem; margin: auto; }";
var deck = new AnkiDeck("German");
deck.AddNote(type, new Dictionary<string, string>
{
["Front"] = "der Baum",
["Back"] = "tree",
});
// Reuse 'type' for subsequent notes; it is frozen after the first AddNote call.
Builds one named deck hierarchy and acts as the root for validation and export.
Definition AnkiDeck.cs:31
Creates fresh conventional Basic, reversed, and Cloze definitions for callers that need direct contro...
static AnkiNoteType CreateBasicAndReversed()
Creates a conventional Basic (and reversed) definition that generates two study directions.

Definition at line 30 of file AnkiNoteTypes.cs.

Member Function Documentation

◆ CreateBasic()

AnkiNoteType AnkiIO.AnkiNoteTypes.CreateBasic ( )
inlinestatic

Creates a conventional Basic definition that generates one front-to-back card.

Returns
A new standard note type with Front and Back fields and one card template.

The front renders {{Front}}. The answer reuses {{FrontSide}}, adds Anki's conventional answer rule, then renders {{Back}}. Field values may contain HTML and media references and are not sanitized.

Definition at line 54 of file AnkiNoteTypes.cs.

◆ CreateBasicAndReversed()

AnkiNoteType AnkiIO.AnkiNoteTypes.CreateBasicAndReversed ( )
inlinestatic

Creates a conventional Basic (and reversed) definition that generates two study directions.

Returns
A new standard note type with Front and Back fields and two reciprocal templates.

Every note always generates both directions, front-to-back first and back-to-front second. This is different from Anki's optional-reverse pattern, which conditionally creates a reverse card based on an extra field; create a custom Standard note type when conditional reversal is required.

Definition at line 67 of file AnkiNoteTypes.cs.

◆ CreateCloze()

AnkiNoteType AnkiIO.AnkiNoteTypes.CreateCloze ( )
inlinestatic

Creates a conventional Cloze definition with Text and Extra fields.

Returns
A new cloze note type with Text and Extra fields and one cloze template.

The front and back use {{cloze:Text}}; the answer additionally renders Extra. Cards are generated from distinct positive cloze indexes in Text, not from template count. Use AnkiCloze.Wrap to build simple deletions or supply valid advanced Anki markup yourself through the low-level note API.

Definition at line 80 of file AnkiNoteTypes.cs.


The documentation for this class was generated from the following file: