Skip to content


Technical Summary

The Anki card template is generated through jinja templates, which is a popular templating engine for Python. All of these templates are located under the (root)/src folder.

The Anki templates are generated through a combination of sass (for css) and jinja (for everything else), through the tools/ script.

You must build the note to use compile-time options.

Additionally, if you want to use bleeding edge features (the absolute latest features, which are potentially riddled with bugs), you must build and install the note from the dev branch. More info about this is shown later.


The instructions listed below will be primarily Linux based. Notes for other operating systems may be shown, but are not guaranteed.

It is also assumed that you have knowledge of basic command line.



  • Python 3.10.6 or higher
    • I recommend pyenv to upgrade your python version if you're running linux. and have a lower version of Python.
  • sass (dart implementation)
    • The dart implementation is required to use the latest features of sass.
  • Anki 2.1.49 or higher (2.1.54+ is highly recommended)
  • Anki-Connect addon


The following creates a custom python environment with venv, so that packages aren't installed into your global python environment.

# on fresh installs
git clone
cd jp-mining-note

# alternatively, if you already have the repository on your system:
git pull origin/master

# You may have to use `python` instead of `python3`, and `pip` instead of `pip3`.
python3 -m venv .

# The following is for POSIX (bash/zsh) only.
# See how to activate venv on your system in the official documentation:
source ./bin/activate

pip3 install -r tools/requirements.txt

Some additional options with venv are shown below.

Disabling the venv
Resetting the venv
# run this only if you're already in a venv

rm -r bin lib
python3 -m venv .
source ./bin/activate
pip3 install -r tools/requirements.txt
Don't want to use venv?

It is highly recommended that you use venv, or something else that isolates the python environment.

However, in case you don't want to use venv, you can manually install the dependencies (including dependencies for building documentation):

pip3 install \
        JSON-minify jinja2 black pytest \
        mkdocs mkdocs-video mkdocs-material mkdocs-macros-plugin \


The master branch is the stable version of the note.

If you want to build the bleeding edge version of the note, use the dev branch. For example, do the following:

deactivate # if you are currently in a venv

git fetch
git checkout dev

python3 -m venv .
source ./bin/activate

Building and Installing

After setting up the venv, you are ready to build and install the note.

cd tools

# builds the note into the ./build folder

# installs the note from the ./build folder
# WARNING: completely overrides current note that is installed!
# Please make a backup of your collection before doing this!
python3 --from-build --update


If you are attempting to (build and) install the bleeding edge (dev) version of the note at ALL, use the --dev-output-version="" flag on the (or script. For example:

python3 --dev-output-version=""

There are also some related notes for the current dev build:

  • If you're on 2.1.54 or below, you'll want to add legacy-anki_2-1-54 to the css-folders of the, i.e.

    "css-folders": ["base", "responsive", "dictionaries", "editor-fields", "legacy-anki_2-1-54", "theme", "extra"],

  • The font size of some fields aren't automatically changed yet, so you'll have to adjust them manually in order for it to look nice:

    "WordReadingHiragana": 10,
    "PrimaryDefinitionPicture": 20, # default
    "PAOverrideText": 20, # default
    "YomichanWordTags": 10,
    "IsHintCard": 10,

  • In addition to the above, you would likely want to match the font family with all the other fields, as the font family for new fields is not updated either.


Running the script is exactly equivalent of running the above two commands.


If you are attempting to (build and) install the bleeding edge version of the note on an Anki profile that does NOT already have the note installed, you have to run the installation script twice. For example:

python3 --from-build --update
python3 --from-build --update

Additional things you can do with the project are shown below.

Running Tests

cd tools
python3 -m pytest ./tests

Building the Documentation

To "build" the documentation, all you have to do is the following:

cd docs

# you should now be in (root)/docs, where the mkdocs.yml is.
mkdocs serve

This will allow you to preview the website (usually at

If you are looking to edit the documentation, all related files should be found under this docs folder. The important markdown files are found under:

  L docs
     L docs
        L # the home page
        L ...
     L mkdocs.yml

Common Errors

(TODO) Fill this out as people start working with this note

Last update: January 3, 2023