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.
- Create flashcards directly within your Typst documents.
- Sync these flashcards to a chosen Anki deck effortlessly.
- Streamlined workflow for note-taking and spaced repetition learning.
-
Open Anki and navigate to Tools > Add-ons.
-
Click Get Add-ons and enter the following code to install AnkiConnect:
2055492159Alternatively, 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.
- Install Rust and Cargo by following the instructions at https://www.rust-lang.org/tools/install.
- Install the Typ2Anki package using cargo
[!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.typfile 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
-rflag 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.typfile 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.typfile 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.
- Command line options: Do
typ2anki --helpto see all available options.- Options include: specifying a max width for cards (to make sure they fit on phones - ex:
--max-card-width 430pt), excluding files or decks
- Options include: specifying a max width for cards (to make sure they fit on phones - ex:
- Configuration file: You can create a
typ2anki.tomlfile in your project directory to customize the behavior oftyp2anki. 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. - Compiling from .zip: You can pass a
.zipfile totyp2ankito compile all Typst files inside it. This is useful so that if you use typst.app you can download your project as a.zipand compile it withtyp2ankiwithout 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
)
}- See examples for a few cards
- Some math cards made using typ2anki: itsvyle/typ2anki-demo
-
AnkiConnect not responding:
- Ensure Anki is running and AnkiConnect is installed correctly.
-
Typst file compilation errors:
- Check for syntax issues in your Typst file.
- Ensure your
ankiconf.typcontains the necessary imports and configurations. - Do note that inside a given card you only have access to the scope that's in the current card. You cannot have any "global" variables in a given file. Any "global" or "shared" variables should be defined in the
ankiconf.typfile.
- Command to Delete Cards: Implement a feature to remove specific cards from Anki.
- Efficiency Improvements: Optimize the syncing process for speed and reliability.
- Support for Other Card Types: Expand compatibility to include more complex card formats.
- Support to use what's previously been set in the file: Allow using context from the file, and not just
ankiconf.typ
- Enhance user experience with more robust error handling and syncing options.
- Broaden integration with Typst to support various output formats.
Contributions 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!