Imports Markdown files into Anki (spaced repetition software) to keep memory of notes fresh.
- Setup Anki and install the AnkiConnect plugin.
- Create a deckConsts.py file in the same directory as main.py with the content:
# Path to the root directory of your markdown notes
ROOT = ""
# Mapping of deck names to markdown directories
DECKS = {
# deck name : markdown directory path
"math::math241": "@2.1/math241" # deck name is math::math241, markdown directory path is @2.1/math241
}
# automatically builds full key/value path mapping
DECKS = {k: ROOT + v for k, v in DECKS.items()}
# if the title of the markdown file contains any of these keywords, it will be ignored
IGNORE_KEYWORDS = "discussion"
# output directory for any errors
OUTPUT_DIR = ""
- Suggested: set up virtual environment and install dependencies
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
- Suggested: set up runners for the
main.py
file. See examples/runners for examples for most operating systems. These are useful when for me to run md-to-anki from macOS Spotlight and the equivalent on Windows/Linux
- LaTeX support via MathJax
- Cloze deletion (both inside and outside MathJax)
- Syntax highlighting (must set up pygments.css in Anki card styles)
- Images (supports Obsidian
[|size](path-to-image.png)
syntax for image size) - Uses anki-connect to automatically add parsed data to Anki
All notes are imported to the cloze type. Any bold text, notated by markdown **bold text**
is converted to cloze
fields.
By default, cloze fields will be numbered in the order they appear in the note. To manually number cloze fields, use
{{c#::text}}
. The automatic counting does not increment in this case.
Double line breaks delineate new cards.
The title of the markdown file is used as the tag for the imported notes. -
in the title denotes a subtag (replaced
with ::).
Alternatively, use headings in the markdown file to denote tags. The first heading will be the main tag, and the second heading will be the subtag, etc.
Folder set up in deckConsts.py
is "math::math240": "blueputty01/math240/"
. A markdown file is processed at
"blueputty01/math240/6 Orthogonality and Least Squares/2 Orthogonal Sets.md"
.
The tag for the imported notes will be #math::#math240::6OrthogonalityandLeastSquares::2OrthogonalSets
.
Indented text refer to text in the extra field for the card directly above.
Alternatively, an extra field may be surrounded by ---
.
The **Articles of Confederation** defined the government that ran the American Revolution.
---
This text is in the extra field
* Land Ordinance Act of 1785
* allowed federal government to sell western lands
* pay off national debt
* organize new lands into townships and public schools
* Northwest Ordinance of 1787
* provided that when new territory reached population of 60K → could apply for statehood with no slavery allowed
---
This is another card; **this text will be marked for cloze**.
This line is in the extra field.
Text:
The {{c1::Articles of Confederation}} defined the government that ran the American Revolution.
Extra:
- Land Ordinance Act of 1785
- allowed federal government to sell western lands
- pay off national debt
- organize new lands into townships and public schools
- Northwest Ordinance of 1787
- provided that when new territory reached population of 60K → could apply for statehood with no slavery allowed
Once a file is successfully parsed, the script will add ***
to the end of the file name to indicate that it has been
processed. If the file has already been processed, it will be skipped.
Feel free to contribute to this project by opening an issue or creating a pull request!
If adding a package, please run pip freeze > requirements.txt
to update the requirements.txt file.
Please ensure that code is typed properly with mypy