Skip to main content

AnkCompiler

coverage

A CLI tool for compiling Anki decks, defined in Markdown.

Installation

Run pip install ankcompiler

Usage

Run ankc --help for usage information.

Main commands:

  • ankc build compiles decks into .apkg packages.
    • Subdecks use Anki's :: naming, e.g. deck: Geo::Rivers. --deck Geo packages Geo and every Geo::... subdeck into one geo.apkg. --all writes one package per top-level deck. Upgrading from 0.3.x: delete old per-subdeck packages (e.g. geo--rivers.apkg) from your output directory so they aren't re-imported.
    • New cards are studied in source order: by deck name, then file path, then position in the file. Anki applies this order to cards it imports for the first time; it doesn't reorder cards already in a collection.
    • To set the order yourself, add a [^pos]: <n> footnote next to a card's [^uid]. <n> is a whole number from 0 to 999999, and lower numbers are studied first. All cards from one note (both sides of a reversed note, every cloze) share its position. Within a package (the deck and subdecks one ankc build writes), use [^pos] on every card or on none. Mixing the two is an error, and so is a position used twice. A package with no [^pos] keeps the source order above. ankc check reports these errors as file:line. ankc uid and ankc uid --fix keep [^pos] lines.
  • Tags: tags: in the frontmatter applies to every card in a file, and a [^tag]: <tag> footnote applies to one card. Footnote tags may use letters, digits, _, - and :: (a hierarchical tag such as tier::1).
  • ankc check validates decks without compiling. It reports problems as file:line, and can print JSON with --format json. It also fails on missing images and on two different images sharing a filename.
  • ankc uid adds a [^uid] footnote to any card block that is missing one. It is append-only and safe to run more than once. Use --check for a dry run. It will not touch files with uncommitted git changes unless you pass --force.
    • Add --fix to also repair a draft deck whose cards are separated by a single ---. It rewrites each card into a well-formed block and stamps any missing uids. Draft fast, then run ankc uid --fix to make the deck buildable. It only restructures real decks (frontmatter with a deck: key), so it is safe on non-drafts.

Examples

See examples/example.md for a deck with every note type, tags, and math.

Note types

  • Question and answer: front ::: back. Found automatically.
  • Cloze: {{c1:: ...}}. Found automatically.
  • Basic and reversed: front ::: back plus [^type]: reversed. This makes a card in both directions.
  • Type in the answer: question ::: answer plus [^type]: type-in.

Reversed and type-in cards use the same ::: syntax as a question and answer card. So you name them with a [^type] footnote next to the [^uid].

Math

Write inline math as $...$ and block math as $$...$$. Anki renders it with MathJax. To show a real dollar sign, write \$.

Credits

Inspiration taken from lukesmurry

Metadata

Release files for ankcompiler 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ankcompiler 0.6.0
File Size Uploaded
ankcompiler-0.6.0.tar.gz 21.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ankcompiler 0.6.0
File Interpreter ABI Platform
ankcompiler-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 49.3 kB

Release files / ankcompiler-0.6.0.tar.gz

Download URL ankcompiler-0.6.0.tar.gz
Size 21.4 kB
Tags Source
SHA-256 checksum
How to use checksums
71b150fb4b38d18fe829fe9a48ffbe2913ff32719860cf0e7a9a0dd0a887b2c6
BLAKE2b-256 checksum
How to use checksums
0698ac2b8cbfe8322ac1eb394ffd47a3bc37a3be862b88724c93731c4420ae40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ankcompiler-0.6.0-py3-none-any.whl

Download URL ankcompiler-0.6.0-py3-none-any.whl
Size 27.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0f545d6fd2db5b071afb1472f3077e20b071827dda2c2acb2952e18f5f2236dc
BLAKE2b-256 checksum
How to use checksums
67c715cf1d84bc83ae57e09a9dd7196f99d33e807f4892eb2245173579c8cd7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page