Convert Markdown formatted documents to anki decks
Project description
md2anki
Convert Markdown formatted documents to anki decks
This was tested on the anki Desktop client, the anki web client and AnkiDroid.
TODO:
- Fix inline code generation without css rule for ALL
<p>
tags - Add tests for anki note generation
- Enable inline code execution to additionally generate:
- Graphs
- LaTeX
tikzpicture
- LaTeX
- Graphs
Features
-
Create an anki deck
.apkg
file -
The name of the deck and its notes will be updated on your next deck import (this works via automatic IDs, deletions can not be tracked!)
-
Very simple basic structure that supports additionally anki note tags and anki subdecks:
-
Supported question/answer content:
- LaTeX math (inline and blocks)
- Images (local files and URLs, vector and raster format)
- Code (inline and blocks)
- All basic Markdown features (i.e. tables, bold, italics, lines)
-
Merge notes from multiple markdown input files into a single deck output file
-
Export document and all used local assets to a custom directory that can easily be shared or used as backup
To evaluate code and export to pdf the following additional software needs to be installed:
# Linux (the apt package manager is just an example)
sudo apt install clang librsvg2-bin nodejs pandoc texlive-xetex
# Windows (the choco package manager is just an example)
choco install llvm miktex nodejs pandoc rsvg-convert
# Both
npm install -g ts-node
# > For matplotlib python graphs in examples:
python -m pip install numpy matplotlib
Examples
Checkout the examples
directory for more examples.
# Example 'Basic' (3714486828)
## One line question (66b3661f-e22e-4986-a50d-569fdac454ad)
One line answer
## Multi line (24501c1a-f615-4355-a862-a00f64cc4725)
question thanks to a question answer separator (`---`)
---
Answer that has multiple lines.
**Basic** *Markdown* and <ins>HTML</ins> <del>formatting</del> is supported.
## Question with multiple (parenthesis) (is) (possible) (b7b85393-b76d-43e6-965a-d86108bf5b09)
Answer
## Lines in answers with multiple `---` (f0e03cb6-2015-4f64-bcd3-51e24763705b)
First question answer seperator in the question.
---
Answer
---
Second part of answer with a line before it.
# Example 'Subdeck' (750441971)
Example document to show how subdecks work.
`{=:global_tag:=}`
## Question 1 (f51d6aa5-1e39-4ad7-94fb-042f7084eff5)
Answer
## Subdeck: Subdeck Heading 1 (406542328)
All notes of the level 3 will be added to this subdeck.
`{=:subdeck_tag_1:=}`
### Question 1.1 (583813da-5766-4cb8-b39f-ae0337e1f13c)
Answer
## Question 1.2 (f51d6aa5-1e39-4ad8-94fb-047f7094eff5)
Answer
## Subdeck: Subdeck Heading 2 (406541128)
`{=:subdeck_tag_2:=}`
### Question 2.1 (583813da-5766-4cb8-b39f-ae0337e1f13c)
Answer
### Subdeck: Subdeck Heading 3 (406641128)
All notes of the level 4 will be added to this subdeck.
`{=:subdeck_subdeck_tag:=}`
#### Question 3.1 (583813da-5786-4cb8-b39f-ae0337e1f13c)
Answer
### Question 2.2 (583223da-5786-4cb8-b39f-ae0337e1f13c)
Answer
Usage
usage: md2anki [-h] [-v] [-d] [-anki-model MODEL_ID] [-o-anki APKG_FILE]
[-o-md MD_FILE] [-o-md-dir MD_DIR] [-o-backup-dir BACKUP_DIR]
[-o-pdf PDF_FILE] [-file-dir [FILE_DIR ...]]
[-md-heading-depth HEADING_DEPTH]
MD_INPUT_FILE [MD_INPUT_FILE ...]
Create an anki deck file (.apkg) from one or more Markdown documents. If no
custom output path is given the file name of the document (+ .apkg) is used.
positional arguments:
MD_INPUT_FILE Markdown (.md) input file that contains anki deck
notes
options:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-d, --debug enable debug output
-anki-model MODEL_ID custom anki card model (md2anki_default,
md2anki_type_answer) [default: md2anki_default]
-o-anki APKG_FILE custom anki deck (.apkg) output file path
-o-md MD_FILE custom updated (and merged if multiple input files)
Markdown (.md) output file path for all input files
-o-md-dir MD_DIR custom output directory for all updated Markdown (.md)
input files
-o-backup-dir BACKUP_DIR
create a backup of the anki deck (i.e. merges input
files and copies external files) in a directory
-o-pdf PDF_FILE create a PDF (.pdf) file of the anki deck (i.e. merges
input files and removes IDs)
-file-dir [FILE_DIR ...]
add directories that should be checked for referenced
files (like relative path images)
-md-heading-depth HEADING_DEPTH
use a custom Markdown heading depth (>=1) [default: 1]
Setup
Via the file setup.py
the package can be built and installed.
Build
The following commands create the package files in a new directory called dist
:
md2anki-$CURRENT_VERSION-py3-none-any.whl
md2anki-$CURRENT_VERSION.tar.gz
python -m pip install --upgrade build
python -m build
Install
The wheel (.whl
) file can be installed and uninstalled via pip
:
# Install package
pip install dist/md2anki-$CURRENT_VERSION-py3-none-any.whl
# Uninstall package
pip uninstall md2anki
Markdown Editors
A list of editors which support WYSIWYG editing of such Markdown documents (source code and math blocks):
- Typora (paid, free to use until version 0.9)
- Visual Studio Code (open source)
Dependencies
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 md2anki-3.0.2b0.tar.gz
.
File metadata
- Download URL: md2anki-3.0.2b0.tar.gz
- Upload date:
- Size: 24.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d0f0814e01d7517ee30c60505c374ae6abb8b7922790aa20e8883d31b52cda7 |
|
MD5 | 1be39383fdeb7473241683723dceb565 |
|
BLAKE2b-256 | 27d13587e0944d07f46718d89df854c1b99b69f24df1d77637a8ff7a04fc566e |
File details
Details for the file md2anki-3.0.2b0-py3-none-any.whl
.
File metadata
- Download URL: md2anki-3.0.2b0-py3-none-any.whl
- Upload date:
- Size: 26.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bf22fc119976529d0c6286cf84028b3c06620302a582e9c6b7e71b9b55d1c88 |
|
MD5 | 8467abf61f4f7a249a683927b572f6e9 |
|
BLAKE2b-256 | a91dcb532c92da354fe7f5568576076564b2ea8cf68b282b9e5031db04a9dcf1 |