Generate an Anki deck from annotations on a text file
Project description
Purpose
The purpose of this tool is to generate an Anki deck from annotations on a text file. This was specially developed for those who use Anki to learn language vocabulary.
Input structure
- The input must be some sort of non-compressed text file (.txt, .md, etc.)
- Every line to be converted to an Anki card must start with a marker, such as
-
. Use themarker
option to set a custom marker. Every other line will be ignored. - The front and back of the cards are separated by a separator, such as
=
. Use theseparator
option to set a custom separator.
Example:
- die Katze = the cat
- das Haus = the house
Outside of these rules, you are free to populate your text file with other annotations which will be ignored when creating the deck.
Current card types
Currently, the output deck will be populated with cards from one type at a time. The currently implemented types are:
basic
: The Basic card type in Anki. Each line's text is split between front and back of one card by theseparator
sound
: Similar to the Basic (type in the answer) card type, but with an added empty field on the back of the card that can be filled up afterwards with (for example) sound files by using an add-on such as HyperTTS
Installation
Make sure you have python installed (version >= 3.12) and then run in the terminal/command-line:
pip install anki_deck_from_text
How to run
Open a terminal/command-line instance and follow the general structure:
anki_deck_from_text file_name.md output_name amazing_deck_name
For all options run:
anki_deck_from_text --help
You will get the following documentation:
anki_deck_from_text [OPTIONS] INPUT OUTPUT DECK_NAME
Generate and Anki deck from annotations on a text file.
INPUT is the text file. OUTPUT is the desired name for the .apkg file with
the deck. DECK_NAME is the deck name that will be displayed in Anki.
Options:
--separator TEXT Character(s) that separate the text to be written to the
front and back of the cards [default: =]
--marker TEXT Character(s) marking this line to be included in the deck
[default: -]
--card_model TEXT Anki card model to build the deck with. Available options
are: `basic`, `sound` [default: basic]
-h, --help Show this message and exit.
Further development
Contributing
To contribute to this project:
- Fork this project
- Install Poetry
- Install Nox (optional but recommended for automated tests and code formatting)
- Change to the project directory and run
$ poetry install
This should get your system setup to:
- Test that your changes didn't break the tool with
$ nox
orpoetry run pytest
- Build with
$ poetry build
(optional) - Test run with
$ poetry run anki_deck_from_text ...
Once you're happy with your changes and tests: 5. Create a pull request to be reviewed
Extending the tool
Add card types
To add extra card types follow the instructions in the models.py
file docstring and then update the current available card types both in the docstring of generate_deck.py
and in the relevant section of this README.
Refer to the Anki docs for how to design Anki card type structures.
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
File details
Details for the file anki_deck_from_text-1.3.4.tar.gz
.
File metadata
- Download URL: anki_deck_from_text-1.3.4.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.2 Linux/6.2.0-1019-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a63ebdddd21876bf2671c6589d9b8f1968b5f98eefdb1e41d3c7d45284f168d8 |
|
MD5 | e3a2c23ae53dfa923c0091036ce5d5d5 |
|
BLAKE2b-256 | 925769cca5cbc5debc60c20a292c616174cd9c9a8f2d9d5b6ad35a4239113302 |
File details
Details for the file anki_deck_from_text-1.3.4-py3-none-any.whl
.
File metadata
- Download URL: anki_deck_from_text-1.3.4-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.2 Linux/6.2.0-1019-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61367ba9f3230bb70dd8697cb2316f54e644ab84d42490a0a136c5bf4b076ae2 |
|
MD5 | 22bcca0e74684c00ae3adde3bf1c8c00 |
|
BLAKE2b-256 | 9a45fed03e642d43b33fa89efd067c0efba330cd44c1ee5f690d5f58e3377466 |