4.0.4 • Published 6 months ago

anki-apkg-export-updated v4.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

anki-apkg-export

Build Status

Universal module for generating decks for Anki.

Port of the Ruby gem https://github.com/albertzak/anki2

Install

$ npm install anki-apkg-export --save
# or
$ yarn add anki-apkg-export

Usage

const fs = require('fs');
const initSqlJs = require('sql.js');
const { default: AnkiExport } = require('anki-apkg-export');

(async () => {
  const sql = await initSqlJs();
  const apkg = new AnkiExport({
    deckName: 'deck-name-node',
    template: {},
    sql
  });

  apkg.addMedia('anki.png', fs.readFileSync('../assets/anki.png'));

  apkg.addCard('card #1 front', 'card #1 back');
  apkg.addCard('card #2 front', 'card #2 back');
  apkg.addCard('card #3 with image <img src="anki.png" />', 'card #3 back');

  const zip = await apkg.save();

  fs.writeFileSync('./output.apkg', zip, 'binary');
  console.log(`Package has been generated: output.apkg`);
})();

Examples

Changelog

  • v4.0.0 - expose template variables (frontside, backside and css)
  • v3.1.0 - make setting APP_ENV optional
  • v3.0.0 - add tags, ES6 refactor (breaking)
  • v2.0.0 - add media support, update jszip dependency (breaking)
  • v1.0.0 - initial rewrite

Tips

  • issue#25 - Dealing with sql.js memory limits

Related

License

MIT © ewnd9

4.0.4

6 months ago

4.0.3

6 months ago