Load global CSS and JavaScript files for your Anki cards!
Download and run the latest AnkiAssets.ankiaddon
release.
-
Place CSS and JavaScript files into their respective directories within the add-on's
user_files
directory. CSS files go intouser_files/assets/css
and JavaScript intouser_files/assets/javascript
. For example, the following shows the final structure of the add-on's directory when acard.css
,_normalize.css
andcard.js
are added.addons21/AnkiAssets ├── src/ └── user_files ├── assets │ ├── css │ │ ├── _normalize.css <- Here! │ │ └── card.css <- Here! │ └── javascript │ └── card.js <- And here! └── assets.json
Note that files starting with underscores
_
or periods.
are ignored. This allows for the use of CSS-style importing e.g.@import "_normalize.css";
- Run Anki and go to
Tools
>AnkiAssets Preferences...
to enable/disable the assets you want loaded for every card.
┌────────────────────────────────────────────┐
│ AnkiAssets Preferences │
├────────────────────────────────────────────┤
│ CSS: │
│ ┌────────────────────────────────────────┐ │
│ │ ■ card.css │ │
│ │ □ ... │ │
│ └────────────────────────────────────────┘ │
│ JavaScript: │
│ ┌────────────────────────────────────────┐ │
│ │ ■ card.js │ │
│ │ □ ... │ │
│ └────────────────────────────────────────┘ │
│ ┌─────────────┐ ┌─────────┐ ┌───────┐ │
│ └─────────────┘ └─────────┘ └───────┘ │
└────────────────────────────────────────────┘
An example config can be found at: tnahs/anki-addon-configs:AnkiAssets.
-
Install the required
[python-version]
. See the Anki development docs for more information.pyenv install [python-version]
-
Clone this repository.
git clone git@github.com:tnahs/AnkiAssets.git
-
Set
[python-version]
as the local version:cd ./AnkiAssets pyenv local [python-version]
-
Create and enter a virtual environment:
python -m venv .venv source .venv/bin/activate pip install --upgrade pip
-
Install required packages:
pip install -r requirements.txt
-
Set development environment variables. See Anki development | Environment Variables for more information.
Required:
export ANKI_ADDON_DEVELOPMENT=1
Optional:
export ANKIDEV=1 export LOGTERM=1 export DISABLE_QT5_COMPAT=1
-
Run Anki from the terminal.
anki