Ateto : Anki templates tools
ateto is a set of tools to write templates outside of Anki.
Why ?
It’s a collection of scripts I try to reorganize. It started with the Anki addon called Templates Import / Export, a python tool, Anki Template Tester and now … look at this ! Yes, the name is not much creative.
In short, it can :
export models templates (HTML and CSS) from Anki to files (inside $XDG_DATA_HOME/ateto)
take some note as samples from Anki and test the templates with them (producing a file like html_output/Basic.html)
import models templates and some shared medias (like _base.css) to Anki
From the command line, with something like this:
ateto sync # export from anki ateto compile # write test templates files ateto sync -i # import in anki
There is also a shorthand command called ateto and a “watcher”. It’s useful to compile test templates at each modification:
ateto watch
Installation
This should work:
python -m pip install ateto
Requirements
Right now it depends on the AnkiConnect Anki addon and anki-templates-tester that I put inside this project to keep things simple.
Default working directory
The default working directory is $XDG_DATA_HOME/ateto (something like ~/.local/share/ateto). The templates of each Anki “note type” (or “model”) are stored in models_export.
Simple how to
Sync templates with Anki
First, while Anki is running, we need to export models templates with AnkiConnect:
ateto sync
If we change some files in models_export, we can import them in Anki with:
ateto sync -i
Compile test templates
We need to get some sample data from Anki and then compile templates. But first, open Anki and tag some notes with template_test_data:
ateto populate ateto compile
Images and CSS or JS assets
If there is missing images run:
ateto link
All files under the models_export/_medias directory will be linked in html_output with compile -m:
ateto compile -m
But you have to create them first.
Supertemplates
models_export contains template export of Anki notes templates. It’s basic HTML. There is “supertemplates” : it’s Jinja2 templates that we can use to generate the models, they are in supertemplates folder.
To build the supertemplates use -s option with compile:
ateto compile -s
HTML and CSS files in supertemplates are processed, then models_export are converted to html_output.
Watcher
It’s my favorite part. When I’m working on some templates, I want modifications to be automatically compiled in templates and output HTML some I use watch command:
ateto watch
And I want it all, supertemplates, medias and images. I want them to be imported in Anki too. Images are only linked when starting, not watched
ateto watch -ai
More
Debug mode
watch and compile commands can be run with debug mode (-d option). This will run supertemplates with a context where is_debug=True. It’s useful to debug AnkiDroid with something like this in templates files
{% if is_debug %}
<script src="https://cdn.jsdelivr.net/npm/eruda"></script>
<script>eruda.init();</script>
{% endif %}
File tree
So at the end, in $XDG_DATA_HOME, we have 4 main folders
* /supertemplates
ModelName/ directories
.jinja files
.html files
style.css file
_medias/ directory (optional)
.css files
.js files
/models_export
ModelName/ directories
CardName.html files
style.css file
_medias/ directory (optional)
.css files
.js files
/data
ModelName.yaml files
ModelName_override.yaml optional files
/html_output
ModelName.html files
ModelName.css files
.css files linked from models_export/_medias
.js files linked from models_export/_medias
.png, .jpg, etc. files linked from anki_collection
The content of supertemplates is only created by hand and compiled into models_export.
All the content of models_export is synced with Anki (Ankiconnect). _medias are treated with a special procedure.
The content of data is populated from Anki. _override.yaml files are created by hand if necessary.
html_output is the result of different actions :
ModelName.html and ModelName.css files are the result of models_export and data files
others CSS or JS are linked to models_export/_medias
images are linked to the Anki collection
Metadata
Release files for ateto 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ateto-0.2.1.tar.gz | 16.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ateto-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.7 kB
Release files / ateto-0.2.1.tar.gz
| Download URL | ateto-0.2.1.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ddfe3ccbf0a9278e3bab2e3c0cc2e282a199dee3af79f078f721cef1a4d53117
|
|
BLAKE2b-256 checksum How to use checksums |
fe43e90d828afc0dd69bc86bad0448617c1d3154c5cdf2567aa447797ecbc98b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.10.4 Linux/5.15.81-1.fc32.qubes.x86_64
|
Release files / ateto-0.2.1-py3-none-any.whl
| Download URL | ateto-0.2.1-py3-none-any.whl |
|---|---|
| Size | 17.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8dcdf440e63c7040aacb3d64e17f27216c6697a651eaba69483209f4e2baa645
|
|
BLAKE2b-256 checksum How to use checksums |
a23a22204200b63b85f9e9af3cbe8133581f1bf815fa56b1dc9eebcff51700cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.10.4 Linux/5.15.81-1.fc32.qubes.x86_64
|
Security for ateto 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.