| Crates.io | typ2anki |
| lib.rs | typ2anki |
| version | 1.0.9 |
| created_at | 2025-11-17 19:28:13.112864+00 |
| updated_at | 2026-01-14 14:25:12.487043+00 |
| description | Compile Typst flashcards into Anki decks |
| homepage | https://github.com/sgomezsal/typ2anki |
| repository | https://github.com/sgomezsal/typ2anki |
| max_upload_size | |
| id | 1937375 |
| size | 229,563 |
Typ2Anki is a tool designed to integrate flashcard creation seamlessly into your Typst-based notes. By utilizing a custom Typst package, you can create cards directly in your notes and sync them effortlessly to a selected Anki deck. This enables you to transform study material into flashcards without disrupting your Typst workflow.
Open Anki and navigate to Tools > Add-ons.
Click Get Add-ons and enter the following code to install AnkiConnect:
2055492159
Alternatively, visit the AnkiConnect Add-on page to learn more.
Restart Anki to activate the add-on.
Verify that AnkiConnect is running by visiting http://localhost:8765 in your browser. If it loads, the add-on is properly installed and functioning.
[!Note] It is recommended to get cargo-binstall for faster installation, as the build process of typ2anki can take some time.
cargo binstall typ2anki --locked || cargo install typ2anki --locked
Verify the installation:
typ2anki --help
On systems with nix installed and flakes enabled, the python package can be executed with the following command:
nix run github:sgomezsal/typ2anki
Add the Typ2Anki package to your Typst document:
#import "@preview/typ2anki:0.1.0": *
After installing the Rust package, you can run the following command to set up the Typst package:
typ2anki --install-typst-pkg
Navigate to your flashcards directory:
cd ~/Documents/Flashcards/ # or your preferred location
Create your ankiconf.typ file with basic configurations:
// Custom imports for flashcards
#import "@local/typ2anki:0.1.0": *
#import "@preview/pkgs"
#let conf(
doc,
) = {
// Custom configurations
doc
}
Create a new Typst document (e.g., main.typ):
#import "ankiconf.typ": *
#show: doc => conf(doc)
#card(
id: "001",
target-deck: "Target-Deck",
q: "Question",
a: "Answer"
)
Run typ2anki in your project directory:
typ2anki .
If you encounter issues with the package import, you can set up the package manually:
Clone the repository:
git clone https://github.com/sgomezsal/typ2anki
cd typ2anki
Create the local package directory:
mkdir -p ~/.local/share/typst/packages/local/typ2anki/0.1.0
Copy the package files (note the -r flag for recursive copy):
cp -r src/ typst.toml ~/.local/share/typst/packages/local/typ2anki/0.1.0
Navigate to your flashcards directory:
cd ~/Documents/Flashcards/ # or your preferred location
Create your ankiconf.typ file with basic configurations:
// Custom imports for flashcards
#import "@local/typ2anki:0.1.0": *
#import "@preview/pkgs"
#let conf(
doc,
) = {
// Custom configurations
doc
}
Create a new Typst document (e.g., main.typ):
#import "ankiconf.typ": *
#show: doc => conf(doc)
#card(
id: "001",
target-deck: "Target-Deck",
q: "Question",
a: "Answer"
)
Run typ2anki in your project directory:
typ2anki .
Create a Typst file with flashcards:
#import "ankiconf.typ": *
#show: doc => conf(doc)
#card(
id: "001",
target-deck: "Typst",
q: "What is Typst?",
a: "A modern typesetting system."
)
Create your ankiconf.typ file with basic configurations:
// Custom imports for flashcards
#import "@preview/typ2anki:0.1.0"
#import "@preview/pkgs"
#let conf(
doc,
) = {
// Custom configurations that will run on the document
doc
}
// Any other global variables or settings can go here - they will be accessible in all cards
Use Typ2Anki to compile all files in the project directory:
typ2anki ./path/to/your/project
Open your Anki deck to check the newly added flashcards.
typ2anki --help to see all available options.
--max-card-width 430pt), excluding files or deckstyp2anki.toml file in your project directory to customize the behavior of typ2anki. This file can include default command line options for the project, so you don't have to specify them every time you run the command..zip file to typ2anki to compile all Typst files inside it. This is useful so that if you use typst.app you can download your project as a .zip and compile it with typ2anki without having to extract it first.To modify card appearance, you can define custom card logic:
#let custom-card(
id: "",
q: "",
a: "",
..args
) = {
card(
id: id,
q: q,
a: a,
container: true,
show-labels: true
)
}
AnkiConnect not responding:
Typst file compilation errors:
ankiconf.typ contains the necessary imports and configurations.ankiconf.typ file.ankiconf.typContributions are welcome! Feel free to open issues or submit pull requests for bug fixes, feature enhancements, or documentation improvements.
This project is licensed under the MIT License.
Developed with ❤️ by sgomezsal. Let’s make learning efficient and enjoyable!