Project

ankirb

0.02
No commit activity in last 3 years
No release in over 3 years
A library that lets you export apkg packaged decks for Anki. Designed to deal with creation / exporting and not much else
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.11
~> 5.0
~> 10.0

Runtime

= 0.0.1
~> 0.3
~> 10.5
~> 1.1
~> 1.3
 Project Readme

ankirb

Gem Version Build Status

A basic gem to create Anki decks (.apkg). Supports integrated media (audio, images and videos).

Installation

Add this line to your application's Gemfile:

gem 'ankirb'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ankirb

Usage

require 'ankirb'

#create a deck
deck = Anki::Deck.new 'FancyExampleDeck'

#create a basic card
card = Anki::Card.new(:front=>"What is the french for cheese omelette?", :back=>"Omelette au fromage")

#add audio to the back
card.back << "dexters_lab_omelette.wav"

#add card to the deck
deck.add_card card

#add the reverse version of the card
deck.add_card card.invert 

#export to ~/Anki/Decks/FancyExampleDeck.apkg
Anki::apkg.export deck, "~/Anki/Decks" 

Media types

Media can be added to a card face via the << operator, just pass a string that points to a valid media file and the lib will convert + package the file.

For images, the position of the image in the card can be set by using a placeholder {{img}}.

card = Anki::Card.new :front => "{{img}} text after image", :back => "text before image {{img}}"
card.front << "front_img.jpg"
card.back << "back_img.jpg"

If no placeholder is present the image will just be added at the end. If multiple placeholders are present, they'll be replaced sequentially with the image files added to the card.

As with anki, html tags can be used for more styling in the card content. Card model / css template support may be added in future.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/rkachowski/ankirb.

License

The gem is available as open source under the terms of the MIT License.