Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/krmanik/genanki-js
A JavaScript implementation for generating Anki decks in browser client side
https://github.com/krmanik/genanki-js
anki anki-deck anki-flashcards csv-to-apkg export-anki-deck genanki genanki-js javascript
Last synced: 22 days ago
JSON representation
A JavaScript implementation for generating Anki decks in browser client side
- Host: GitHub
- URL: https://github.com/krmanik/genanki-js
- Owner: krmanik
- License: other
- Created: 2021-07-28T22:49:06.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-12T20:26:53.000Z (over 1 year ago)
- Last Synced: 2024-10-01T09:42:47.553Z (about 1 month ago)
- Topics: anki, anki-deck, anki-flashcards, csv-to-apkg, export-anki-deck, genanki, genanki-js, javascript
- Language: JavaScript
- Homepage: https://genanki.js.org
- Size: 2.25 MB
- Stars: 53
- Watchers: 2
- Forks: 6
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: License.md
Awesome Lists containing this project
README
# genanki-js
A JavaScript implementation for generating Anki decks in browser. This is fork of [mkanki](https://github.com/nornagon/mkanki).# QuickStart
Download [genanki](https://github.com/krmanik/genanki-js/releases) zip file from release pages.The zip file contains two folder
- `dist` : This folder contains `genanki.js` file. If project already configured with [sql.js](https://github.com/sql-js/sql.js), [FileSaver.js](https://github.com/eligrey/FileSaver.js) and [JSZip](https://github.com/Stuk/jszip) then just add `genanki.js` file to project.
- `sample` : This folder contains latest [sql.js](https://github.com/sql-js/sql.js), [FileSaver.js](https://github.com/eligrey/FileSaver.js), [JSZip](https://github.com/Stuk/jszip) and [genanki.js](https://github.com/krmanik/genanki-js). It is ready to use folder.
Alternatively, `genanki.js` can also be loaded from CDN.
```html```
# Documentation
View [Documentation](https://krmanik.github.io/genanki-js/#/)# CSV/TSV to Anki Package
Visit page and select `CSV to APKG` from top menu.
[CSV to APKG](https://krmanik.github.io/genanki-js/demo/index.html#)# Set Up a new project from scratch
1. Download `genanki.js` from `dist` folder and add to the project
```html```
2. Add [sql.js](https://github.com/sql-js/sql.js), [FileSaver.js](https://github.com/eligrey/FileSaver.js) and [JSZip](https://github.com/Stuk/jszip) to the project
>*Note: [mkanki](https://github.com/nornagon/mkanki) uses `better-sql`, `fs` and `archiver`, that make it difficult to be used in browser*
```html
```
3. Create a `SQL` global variable (may be added to index.js)
```js
// The `initSqlJs` function is globally provided by all of the main dist files if loaded in the browser.
// We must specify this locateFile function if we are loading a wasm file from anywhere other than the current html page's folder.
config = {
locateFile: filename => `js/sql/sql-wasm.wasm`
}var SQL;
initSqlJs(config).then(function (sql) {
//Create the database
SQL = sql;
});
```4. Now use following `Examples` to generate and export decks.
*View more examples here [Examples](https://krmanik.github.io/genanki-js/#/examples)*
# Examples
```js
var m = new Model({
name: "Basic (and reversed card)",
id: "1543634829843",
flds: [
{ name: "Front" },
{ name: "Back" }
],
req: [
[ 0, "all", [ 0 ] ],
[ 1, "all", [ 1 ] ]
],
tmpls: [
{
name: "Card 1",
qfmt: "{{Front}}",
afmt: "{{FrontSide}}\n\n
\n\n{{Back}}",
},
{
name: "Card 2",
qfmt: "{{Back}}",
afmt: "{{FrontSide}}\n\n
\n\n{{Front}}",
}
],
})
var d = new Deck(1276438724672, "Test Deck")d.addNote(m.note(['this is front', 'this is back']))
var p = new Package()
p.addDeck(d)p.writeToFile('deck.apkg')
```# License
### [genanki-js](https://github.com/krmanik/genanki-js)
[GNU Affero General Public License v3](https://opensource.org/licenses/AGPL-3.0)
Copyright (c) 2021 Mani## Other Third Party Licenses
[License.md](https://github.com/krmanik/genanki-js/blob/master/License.md)