Sync mnemonic markdown files to Anki with rich cloze deletion syntax
Project description
MNMD Anki Sync
Sync mnemonic markdown files to Anki with rich cloze deletion syntax.
Features
- Rich cloze syntax: Basic, grouped, and sequence clozes
- Hints and extras: Add hints (
{{answer|hint}}) and extra info ({{answer<extra}}) - Math support: LaTeX equations (
$inline$and$$block$$) automatically converted to Anki format - Markdown rendering: Bold, italic, lists, images, code blocks, line breaks
- Scope control: Specify paragraph context for each cloze with
[-before,after] - Smart updates: Automatically tracks Anki IDs to prevent duplicates
- Editor links: Open source files from Anki in VS Code, VSCodium, Neovim, or Obsidian
- Dry-run mode: Preview changes before syncing with
--dry-run - Type-safe: Built with Pydantic for robust data validation
- Well-tested: 276 unit tests with 96% code coverage
Installation
For Users
Recommended: Install with pipx (installs in isolated environment)
pipx install mnmd-anki-sync
Alternative: Install with pip
pip install mnmd-anki-sync
Or install with uv
uv pip install mnmd-anki-sync
Install from GitHub (latest development version)
pip install git+https://github.com/am-campbell/mnmd-anki-sync.git
For Developers
Clone the repository and install with uv:
git clone https://github.com/am-campbell/mnmd-anki-sync.git
cd mnmd-anki-sync
uv sync --extra dev
Quick Start
-
Make sure Anki is running with AnkiConnect installed
-
View the syntax guide:
mnmd syntax
- Create a markdown file with cloze deletions:
> ?
> The capital of France is {{Paris}}.
> ?
> My favorite languages are {{1>Python}} and {{1>Rust}}.
- Sync to Anki:
mnmd sync myfile.md --deck "My Deck"
Syntax Guide
See syntax-notes.md for complete syntax documentation.
Basic Cloze
> ?
> The capital of France is {{Paris}}.
Creates one card with "The capital of France is [...]"
Grouped Cloze
> ?
> My favorite languages are {{1>Python}} and {{1>Rust}}.
Both items are hidden together on the same card: "My favorite languages are [...] and [...]"
Sequence Cloze
> ?
> My Haiku:
> {{1.1>I want to write an}}[-1]
> {{1.2>Example poem for you}}
> {{1.3>Hopefully helpful}}
Creates progressive reveal: first line hidden, then second, then third
Hints and Extras
> ?
> Python is a {{dynamically typed|type checking happens at runtime}} language.
> The package manager is {{pip<PyPI hosts over 400,000 packages}}.
|hintadds hint text shown on card back<extraadds extra information (no closing>)- Combine:
{{answer|hint<extra}}
Math Support
> ?
> Einstein's equation: {{$E = mc^2$}}
> The quadratic formula: {{$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$|solves ax² + bx + c = 0}}
LaTeX math is automatically converted to Anki's format
Images
> ?
> The Python logo: 
Standard markdown images work in Anki cards
Scope Control
{{text}}[-1,2]
Include 1 paragraph before, 2 after. Default is current paragraph only.
- Negative numbers = paragraphs before
- Positive numbers = paragraphs after
- Lists default to
[-1](include paragraph before)
CLI Commands
# Sync files
mnmd sync file.md --deck "Biology" --tags "chapter1"
# Sync with specific editor
mnmd sync file.md --editor nvim
mnmd sync file.md --editor vscode
# Validate syntax
mnmd validate file.md
# Show syntax guide (opens in pager)
mnmd syntax
# Show syntax guide without pager (direct output)
mnmd syntax --no-pager
# Show version
mnmd version
Editor Configuration
Set your preferred editor for source links in Anki cards. Choose from:
vscode- Visual Studio Code (default, works out of box)vscodium- VSCodium (works out of box)obsidian- Obsidian (works out of box)file- System default handler (works out of box)nvim- Neovim (requires setup, see EDITOR_SETUP.md)
Config file (~/.mnmdrc):
editor_protocol: vscode # or nvim, vscodium, obsidian, file
default_deck: My Deck
default_tags:
- mnmd
Command line:
mnmd sync file.md --editor nvim
For Neovim users: The nvim:// protocol requires custom setup. Either:
- Use
fileprotocol (easiest):editor_protocol: file - Register
nvim://handler (see EDITOR_SETUP.md)
The file protocol opens files with your system's default markdown editor.
Development
# Run tests
uv run pytest
# Type check
uv run mypy src
For AI Agents & LLM Integration
If you're building tools that generate mnemonic markdown or integrating LLMs to create flashcards, see agents-syntax.md for:
- Precise syntax specification optimized for LLM parsing
- Complete pattern reference with regex-like precision
- Common pitfalls and error prevention
- Validation checklist
- Quick reference table
This file provides unambiguous rules for programmatic generation of valid MNMD syntax.
Contributing
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new features
- Ensure all tests pass:
uv run pytest - Submit a pull request
Publishing & Distribution
See DISTRIBUTION.md for instructions on publishing releases to PyPI and GitHub.
License
Apache 2.0 - See LICENSE file for details
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mnmd_anki_sync-0.1.0.tar.gz.
File metadata
- Download URL: mnmd_anki_sync-0.1.0.tar.gz
- Upload date:
- Size: 33.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6c4ffef7c92889787ac17d0692cb51241e7b49c4db9b67625081be64b9ddc9a
|
|
| MD5 |
505558a34dbcc08806c674ab0943acc5
|
|
| BLAKE2b-256 |
e8a98473bc7dd1c76240050b5316ed54aa3788846fd011cc500ff4240d91dfd9
|
Provenance
The following attestation bundles were made for mnmd_anki_sync-0.1.0.tar.gz:
Publisher:
release.yml on AM-Campbell/mnmd-anki-sync
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mnmd_anki_sync-0.1.0.tar.gz -
Subject digest:
f6c4ffef7c92889787ac17d0692cb51241e7b49c4db9b67625081be64b9ddc9a - Sigstore transparency entry: 731780364
- Sigstore integration time:
-
Permalink:
AM-Campbell/mnmd-anki-sync@03051729ea328c4fa84233d856f27cb142750a08 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/AM-Campbell
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@03051729ea328c4fa84233d856f27cb142750a08 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mnmd_anki_sync-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mnmd_anki_sync-0.1.0-py3-none-any.whl
- Upload date:
- Size: 42.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee0ec7cfda7ba3dc6539487bd909db0737e23d668901ca014772f92bbf10e367
|
|
| MD5 |
ee4e0e901ced9d8d661b99ffb31f8486
|
|
| BLAKE2b-256 |
610be4036f3bed132e88963e517c8dce39d5328c30c30721c029ad1aa695ea87
|
Provenance
The following attestation bundles were made for mnmd_anki_sync-0.1.0-py3-none-any.whl:
Publisher:
release.yml on AM-Campbell/mnmd-anki-sync
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mnmd_anki_sync-0.1.0-py3-none-any.whl -
Subject digest:
ee0ec7cfda7ba3dc6539487bd909db0737e23d668901ca014772f92bbf10e367 - Sigstore transparency entry: 731780366
- Sigstore integration time:
-
Permalink:
AM-Campbell/mnmd-anki-sync@03051729ea328c4fa84233d856f27cb142750a08 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/AM-Campbell
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@03051729ea328c4fa84233d856f27cb142750a08 -
Trigger Event:
push
-
Statement type: