Git Product home page Git Product logo

ankiorg's Introduction

AnkiOrg

AnkiOrg is an add-on to Emacs anki-editor which can pull notes from Anki, convert them to anki-editor’s org representation of an Anki note, and insert them into an org-mode buffer. It provides two ways of interfacing with Anki: either via Anki-Connect or by more directly accessing the Anki SQL database using emacs-sqlite3-api (this can be faster and works when Anki is not running). The html notes returned by Anki are converted to org using pandoc.

Currently, the code is still a bit messy (TODO), but I’ve been successfully using this to export all my existing Anki decks to org when migrating to anki-editor. From that moment on I’ve been managing all my Anki notes from Emacs using anki-editor. It works great! In my Emacs-Anki workflow, I also make use of org-transclusion for providing card context and math-preview for previewing MathJax equations.

Since I started working on this, org-anki has emerged as a feasible alternative to anki-editor (whose original repository is unmaintained) and the pull features provided in this package. However, org-anki does not provide all the features of anki-editor and AnkiOrg, so this might still be an alternative worth exploring. (TODO: Write more detailed comparison.)

Installation

First install the following dependencies outside Emacs: Emacs, Anki, Anki-Connect, curl, and pandoc. Make sure curl and pandoc are in the path used by Emacs. Optionally, to use the SQLite interface you also need emacs-sqlite3-api.

Note: Not all versions of Anki/Anki-Connect may work. Versions which have been tested and work include Anki version 2.1.54 and 24.04.1, and Anki-Connect version 22.7.14.0 and 24.2.26.0.

Next, install the latest version of anki-editor, anki-editor/anki-editor. (The original repository louietan/anki-editor is not maintained anymore.)

Finally, you should now have all dependencies and can install this package in whatever way you like.

I use the following to install this package and the other necessary Emacs packages with straight.el:

(use-package sqlite3
  :straight (:host github :repo "pekingduck/emacs-sqlite3-api"))

(use-package anki-editor  
  :straight (:host github :repo "anki-editor/anki-editor"))

(use-package ankiorg
  :straight (:host github :repo "orgtre/ankiorg")
  :custom
  (ankiorg-sql-database
   "my-path-to/collection.anki2")
  (ankiorg-media-directory
   "my-path-to/img"))

Usage

From an org buffer, run the command ankiorg-pull-notes and select the deck you want to pull. (TODO: Write function to pull all decks.) The org representations of the Anki notes will be inserted into the buffer. Next run command ankiorg-buffer-get-media-files from the same buffer to get the media files linked in the buffer from Anki and save them to your ankiorg-media-directory. (TODO: Make this one call.)

To use the SQL interface, enable ankiorg-sql-minor-mode. It is strongly recommended that you work with a (recent) copy of your Anki SQL database, whose path needs to be set in ankiorg-sql-database. Anki and Anki-Connect need to be running when using the Anki-Connect interface, and (for now) also when retrieving media files. (TODO: Allow retrieving media files via the SQL interface too.) (TODO: Write a detailed usage example.)

Limitations and known issues

ankiorg-pull-notes is not a perfect inverse of anki-editor-push-notes. The main issue is that some line breaks are not properly preserved. I use a bunch of regex’s in the output buffer to correct for most of this. (TODO: Integrate these into the package and fix this better.)

Also, if you use Anki’s buttons for creating nested lists (via the insert list and indent buttons), there is an unfixed Anki bug which causes pandoc to parse nested lists incorrectly. The default regex replacement in the variable ankiorg-anki-replacements should correct for this up to one level of nesting, but not further.

Pull requests, issue reports, and suggestions are most welcome! To encourage contributions, I have used the TODO keyword for marking some outstanding tasks both in this readme and the source code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.