ランキングに戻る

ObsidianToAnki/Obsidian_to_Anki

Python

Script to add flashcards from text/markdown files to Anki

ankianki-scriptpythonobsidianobsidian-mdobsidian-pluginflashcardsadd-flashcardstypescript
スター成長
スター
2k
フォーク
197
週間成長
Issue
241
5001k1.5k2k
2020年9月2022年8月2024年8月2026年7月
成果物PyPIpip install obsidian_to_anki
README

Obsidian_to_Anki

Plugin to add flashcards from a text or markdown file to Anki. Run in Obsidian as a plugin, or from the command-line as a python script. Built with Obsidian markdown syntax in mind. Supports user-defined custom syntax for flashcards.
See the Trello for planned features.

Getting started

Check out the Wiki! It has a ton of information, including setup instructions for new users. I will include a copy of the instructions here:

Setup

All users

  1. Start up Anki, and navigate to your desired profile.
  2. Ensure that you've installed AnkiConnect.

Obsidian plugin users

  1. Have Obsidian downloaded
  2. Search the 'Community plugins' list for this plugin
  3. Install the plugin.
  4. In Anki, navigate to Tools->Addons->AnkiConnect->Config, and change it to look like this:
{
    "apiKey": null,
    "apiLogPath": null,
    "webBindAddress": "127.0.0.1",
    "webBindPort": 8765,
    "webCorsOrigin": "http://localhost",
    "webCorsOriginList": [
        "http://localhost",
        "app://obsidian.md"
    ]
}
  1. Restart Anki to apply the above changes
  2. With Anki running in the background, load the plugin. This will generate the plugin settings.

You shouldn't need Anki running to load Obsidian in the future, though of course you will need it for using the plugin!

To run the plugin, look for an Anki icon on your ribbon (the place where buttons such as 'open Graph view' and 'open Quick Switcher' are). For more information on use, please check out the Wiki!

Python script users

  1. Install the latest version of Python.
  2. If you are a new user, download obstoanki_setup.py from the releases page, and place it in the folder you want the script installed (for example your notes folder).
  3. Run obstoanki_setup.py, for example by double-clicking it in a file explorer. This will download the latest version of the script and required dependencies automatically. Existing users should be able to run their existing obstoanki_setup.py to get the latest version of the script.
  4. Check the Permissions tab below to ensure the script is able to run.
  5. Run obsidian_to_anki.py, for example by double-clicking it in a file explorer. This will generate a config file, obsidian_to_anki_config.ini.

Permissions

The script needs to be able to:

  • Make a config file in the directory the script is installed.
  • Read the file in the directory the script is used.
  • Make a backup file in the directory the script is used.
  • Rename files in the directory the script is used.
  • Remove a backup file in the directory the script is used.
  • Change the current working directory temporarily (so that local image paths are resolved correctly).

Features

Current features (check out the wiki for more details):

  • Custom note types - You're not limited to the 6 built-in note types of Anki.
  • Custom scan directory
    • The plugin will scan the entire vault by default
    • You can also set which directory (includes all sub-directories as well) to scan via plugin settings
  • Ignore Folders and Files
    • You can specify which files and folders to ignore
    • This can be done in the settings of this plugin with Glob syntax.
    • If you're working on your own globs, you can test them out here
    • Examples:
      • **/*.excalidraw.md - Ignore all files that end in .excalidraw.md
        • => avoids excalidraw files from being scanned which can be extremely slow
      • Template/** - Ignore all files in the Template folder (including subfolders)
      • **/private/** - Ignore all files in folders that are called private no matter where they are in the vault
      • [Pp]rivate*/** - Ignore all files and folders in the root of the vault that start with private or with Private
  • Updating notes from file - Your text files are the canonical source of the notes.
  • Tags, including tags for an entire file.
  • Adding to user-specified deck on a per-file basis.
  • Markdown formatting.
  • Math formatting.
  • Embedded images. GIFs should work too.
  • Audio.
  • Auto-deleting notes from the file.
  • Reading from all files in a directory automatically - recursively too!
  • Inline Notes - Shorter syntax for typing out notes on a single line.
  • Easy cloze formatting - A more compact syntax to do Cloze text
  • Frozen Fields
  • Obsidian integration - A link to the file that made the flashcard, full link and image embed support.
  • Custom syntax - Using regular expressions, add custom syntax to generate notes that make sense for you. Some examples:
    • RemNote single-line style. This is how to use::Remnote single-line style
      Remnote 1
    • Header paragraph style.
    # Style
    This style is suitable for having the header as the front, and the answer as the back
    

    Header 1

    • Question answer style.
    Q: How do you use this style?
    A: Just like this.
    

    Question 1

    • Neuracache #flashcard style.
    In Neuracache style, to make a flashcard you do #flashcard
    The next lines then become the back of the flashcard
    

    Neuracache 1

    • Ruled style
    How do you use ruled style?
    ---
    You need at least three '-' between the front and back of the card.
    

    Ruled 1

    • Markdown table style
    | Why might this style be useful? |
    | ------ |
    | It looks nice when rendered as HTML in a markdown editor. |
    

    Table 2

    • Cloze paragraph style
    The idea of {cloze paragraph style} is to be able to recognise any paragraphs that contain {cloze deletions}.
    

    Cloze 1

Note that all custom syntax is off by default, and must be programmed into the script via the config file - see the Wiki for more details.

Buy Me a Coffee at ko-fi.com

関連リポジトリ
ankidroid/Anki-Android

AnkiDroid: Anki flashcards on Android. Your secret trick to achieve superhuman information retention.

KotlinGNU General Public License v3.0ankiandroid
11.4k2.9k
open-spaced-repetition/fsrs4anki

A modern Anki custom scheduling based on Free Spaced Repetition Scheduler algorithm

Jupyter NotebookMIT Licenseanki-addonspaced-repetition-algorithm
github.com/open-spaced-repetition/fsrs4anki/wiki
4k163
5mdld/anki-jlpt-decks

【egg rolls】JLPT N1~N5 一万词 Anki 牌组【简/繁】【语音&例句】;Anki,日语,日文,日本語,牌组,卡组,牌組,卡組,能力考,日檢

HTMLOtherankijapanese
ankiweb.net/shared/info/832276382
2.8k97
kerrickstaley/genanki

A Python 3 library for generating Anki decks

PythonPyPIMIT Licenseanki-flashcardsanki
2.6k196
FooSoft/anki-connect

Anki plugin to expose a remote API for creating flash cards.

PythonPyPIOtheranki
foosoft.net/projects/anki-connect/
2.1k236
tianshanghong/awesome-anki

A curated list of awesome Anki add-ons, decks and resources

awesome-listawesome
2.1k86
tiddly-gittly/TidGi-Desktop

TidGi is an privacy-in-mind, automated, auto-git-backup, freely-deployed knowledge management Desktop note app, based on Tiddlywiki, with REST API for web-clipping and Anki connect. 「 太记 」是一个基于「 太微 TiddlyWiki 」的知识管理桌面应用,能保护隐私内容、高级自动化、自动Git云备份、部署为博客,且可通过RESTAPI与Anki等应用连接。(迭代开发中欢迎试用,开发进度见下方链接)(Under active development, see website below for details)

TypeScriptnpmMozilla Public License 2.0tiddlywiki5tiddlywiki
tidgi.fun
2k116
ninja33/ODH

A chrome extension to show online dictionary content.

JavaScriptnpmMIT Licenseankichrome-extension
1.6k291
ripose-jp/Memento

An mpv-based video player for studying Japanese

C++GNU General Public License v2.0japaneseanki
ripose-jp.github.io/Memento/
1.5k63
simjanos-dev/LinguaCafe

LinguaCafe is a self-hosted software that helps language learners read foreign languages.

VueGNU General Public License v3.0language-learninganki
simjanos-dev.github.io/LinguaCafeHome/
1.4k68
glutanimate/review-heatmap

Anki add-on to help you keep track of your review activity

PythonPyPIOtherankianki-addon
ankiweb.net/shared/info/1771074083
1.3k101
FooSoft/yomichan

Japanese pop-up dictionary extension for Chrome and Firefox.

JavaScriptnpmOtherankichrome
foosoft.net/projects/yomichan
1.1k376