Expand description
TOML-based Anki deck builder with .apkg generation and AnkiConnect import.
This crate provides a unified way to define Anki decks using TOML and then either:
- Generate .apkg files for direct import into Anki
- Import directly into a running Anki instance via AnkiConnect
§Features
apkg(default): Enable .apkg file generationconnect(default): Enable AnkiConnect import
§Example TOML Format
[package]
name = "Spanish Vocabulary"
version = "1.0.0"
author = "Your Name"
[[models]]
name = "Basic Spanish"
fields = ["Spanish", "English", "Example"]
[[models.templates]]
name = "Spanish -> English"
front = "{{Spanish}}"
back = "{{FrontSide}}<hr>{{English}}"
[[decks]]
name = "Spanish::Vocabulary"
description = "Core Spanish vocabulary"
[[notes]]
deck = "Spanish::Vocabulary"
model = "Basic Spanish"
tags = ["chapter1"]
[notes.fields]
Spanish = "el gato"
English = "the cat"
Example = "El gato es negro."§Usage
§Generate .apkg file
use ankit_builder::{DeckDefinition, ApkgBuilder};
let definition = DeckDefinition::from_file("my_deck.toml").unwrap();
let builder = ApkgBuilder::new(definition);
builder.write_to_file("my_deck.apkg").unwrap();§Import via AnkiConnect
use ankit_builder::{DeckDefinition, ConnectImporter};
let definition = DeckDefinition::from_file("my_deck.toml")?;
let importer = ConnectImporter::new(definition);
let result = importer.import().await?;
println!("Created {} notes", result.notes_created);Re-exports§
pub use error::Error;pub use error::Result;pub use schema::DeckDef;pub use schema::DeckDefinition;pub use schema::MediaDef;pub use schema::ModelDef;pub use schema::NoteDef;pub use schema::PackageInfo;pub use schema::TemplateDef;
Modules§
- cloze
- Cloze deletion helpers for creating flashcards with fill-in-the-blank sections.
- error
- Error types for ankit-builder.
- markdown
- Markdown to HTML conversion for note fields.
- schema
- TOML schema types for deck definitions.
Structs§
- Apkg
Builder - Builder for creating .apkg files from deck definitions.
- Connect
Importer - Imports deck definitions into Anki via AnkiConnect.
- Deck
Builder - Unified builder that can output to either .apkg or AnkiConnect.
- Deck
Diff - Result of comparing a TOML definition against Anki state.
- Deck
Exporter - Exports decks from Anki to TOML format.
- Field
Change - A field that differs between TOML and Anki.
- Import
Result - Result of an import operation.
- Modified
Note - A note that exists in both TOML and Anki but has differences.
- Note
Diff - A note that exists in only one place.
- Resolved
Conflict - A conflict that was resolved.
- Sync
Conflict - A conflict where a note differs between TOML and Anki.
- Sync
Error - An error that occurred during sync.
- Sync
Note - A note involved in sync.
- Sync
Plan - A plan for what sync would do, without executing it.
- Sync
Result - Result of a sync operation.
- Sync
Strategy - Strategy for how to handle sync operations.
- Synced
Note - A note that was synced.
- TagChanges
- Tag differences between TOML and Anki.
Enums§
- Conflict
Resolution - How to resolve conflicts when a note differs between TOML and Anki.