Includes real example files or problematic files May be used for automated tests
  • Rust 68.8%
  • Typst 18.3%
  • Nix 6.6%
  • Handlebars 3.3%
  • Shell 3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-07-28 13:11:43 +02:00
.forgejo/workflows feat: adds workflow 2026-02-10 02:02:02 +01:00
nix chore: fmt 2026-02-10 02:02:08 +01:00
src fix(windows): remove Roaming part of appdata 2026-05-06 09:28:18 +02:00
typ remove blank lines 2026-07-28 13:11:43 +02:00
.envrc fixup: proper settings 2025-12-28 02:19:18 +01:00
.gitignore fix: fixes absurdly high image rendering times 2026-01-11 15:36:01 +01:00
.gitmodules reimplement qa 2026-01-03 02:51:15 +01:00
about.hbs cargo-about setup 2026-01-02 15:53:37 +01:00
about.toml cargo-about setup 2026-01-02 15:53:37 +01:00
Cargo.lock feat: renders image 2026-01-10 00:30:29 +01:00
Cargo.toml chore: fmt 2026-02-10 02:02:08 +01:00
flake.lock rust + nix init 2025-12-26 22:51:35 +01:00
flake.nix chore: remove crane checks 2026-02-10 02:02:08 +01:00
LICENSE Add a LICENSE file 2026-01-02 15:53:37 +01:00
README.md chore: fmt 2026-02-10 02:02:08 +01:00

Typ2anki

Write Anki-Notes with typst

Anki-connect

You need Anki-connect. This allows us to write the files to anki.

Add the following addon:

2055492159

Note: Anki needs to be restarted after the installation.

Steps

Cloning the repo

git clone https://code.ole.blue/typ2anki/typ2anki.git --recurse-submodules

Compile the program

Nix

nix build .?submodules=1#

Or as a flake input

inputs = {
  ...
  typ2anki.url = "git+https://code.ole.blue/typ2anki/typ2anki?submodules=1";
}

then include the package

environment.systemPackages = [
  ...
  inputs.typ2anki.packages.x86_64-linux.default
];

Install the library

typ2anki install

Write typst files

Include the lib

import "@local/typ2anki-rs:0.1.0": card, note, show_all
#show: show_all

If you get a white card with nothing on it, make sure you only have this show rule (#show)

Define a note type

#note(
  name: "MyNoteName",
  fields: ("Field1", "Field2"),
  cards: (
    (name: "Front-and-back", front: "{{Field1}}", back: "{{Field2}}"),
    (name: "Back-and-front", front: "{{Field2}}", back: "{{Field1}}")
  )

  // optionally provide css
  css: "
    .card {
      text-align: center;
    }
  "
)

And then just create your notes

#card(
  // this id will be used to track changes to the card. Don't change it, otherwise your learning progress in anki will be lost.
  id: "1",
  deck: "MyDeck", // or nested with "MyDeck::SubDeck"
  note_type: "MyNoteName",
  Field1: [Some Question],
  Field2: [Some Answer]
)

#card(
  id: "2",
  deck: "MyDeck",
  note_type: "MyNoteName",
  Field1: [Some other Question],
  Field2: [Some other Answer]
)

As this can be very repetitive, you can override the card function with default values:

#let card = card.with(deck: "MyDeck", note_type: "MyNoteName")

#card(
  id: "1",
  Field1: [Some Question],
  Field2: [Some Answer]
)

#card(
  id: "2",
  Field1: [Some other Question],
  Field2: [Some other Answer]
)

Write your files to anki

Make sure you have anki open and run:

typ2anki build file <input.typ>

All your notes have been compiled and pushed to anki.

Examples

Physics SI values (German)

#import "@local/typ2anki-rs:0.1.0": card, note, show_all
#show: show_all

#let card = card.with(render: true, deck: "Physik::Einheiten", note_type: "Einheiten")


#note(
  name: "Einheiten",
  fields: ("Basisgröße", "Basiseinheit"),
  cards: (
    (name: "Front-Back", front: "{{Basisgröße}}", back: "{{Basiseinheit}}"),
    (name: "Back-Front", front: "{{Basiseinheit}}", back: "{{Basisgröße}}"),
  ),
  css: "
    .card {
      text-align: center;
    }
  ",
)

#card(
  id: "1",
  Basisgröße: [Stoffmenge],
  Basiseinheit: [Mol: _mol_]
)

#card(
  id: "2",
  Basisgröße: [Lichtstärke],
  Basiseinheit: [Candela: _cd_]
)

#card(
  id: "3",
  Basisgröße: [Ladung in einer Sekunde durch die \ Querschnittsfläche eines Leiters, wenn $A"(mpere)" = 1$],
  Basiseinheit: [Coulomb: _C_]
)