diff options
| author | Paul Buetow <paul@buetow.org> | 2025-07-18 14:57:30 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-07-18 14:57:30 +0300 |
| commit | 1b3228d4c93f5951a1d6cc0e77a364c3dde3e625 (patch) | |
| tree | 0a7ac6ccf40272db77fd41a050f6bd7ef59e8559 | |
| parent | 3dc094c8916852f404d463302ebe9c4e9062cfdd (diff) | |
fix: complete APKG format with all required Anki fields
Based on Anki-Android database documentation:
- Added 'autoplay' field to deck configuration
- Added 'dyn' field to deck configuration
- Added 'separate' field to new card settings
- Added 'minSpace' field to review settings
- Added 'replayq' field for replay queue
- Added 'tags' array to note type
- Added LaTeX pre/post fields for math support
- Added 'media' arrays to all field definitions
- Added missing collection config fields (schedVer, collapseTime, etc.)
- Fixed 'ivlFct' field in review settings
- Added 'bury' flags to new and review sections
This should resolve all JSON parsing errors when importing APKG files into Anki desktop.
Reference: https://github.com/ankidroid/Anki-Android/wiki/Database-Structure
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
| -rw-r--r-- | internal/anki/apkg_generator.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/internal/anki/apkg_generator.go b/internal/anki/apkg_generator.go index 25f8743..099c146 100644 --- a/internal/anki/apkg_generator.go +++ b/internal/anki/apkg_generator.go @@ -235,6 +235,11 @@ func (g *APKGGenerator) insertCollection(db *sql.DB) error { "curDeck": 1, "newSpread": 0, "dueCounts": true, + "collapseTime": 1200, + "timeLim": 0, + "schedVer": 1, + "curModel": fmt.Sprintf("%d", g.modelID), + "dayLearnFirst": false, } confJSON, _ := json.Marshal(conf) @@ -243,12 +248,15 @@ func (g *APKGGenerator) insertCollection(db *sql.DB) error { "1": map[string]interface{}{ "id": 1, "name": "Default", + "dyn": 0, "new": map[string]interface{}{ "delays": []int{1, 10}, "ints": []int{1, 4, 7}, "initialFactor": 2500, "perDay": 20, "order": 1, + "bury": true, + "separate": true, }, "lapse": map[string]interface{}{ "delays": []int{10}, @@ -262,11 +270,16 @@ func (g *APKGGenerator) insertCollection(db *sql.DB) error { "ease4": 1.3, "fuzz": 0.05, "maxIvl": 36500, + "ivlFct": 1, + "bury": true, + "minSpace": 1, }, "timer": 0, "maxTaken": 60, "usn": 0, "mod": now, + "autoplay": true, + "replayq": true, }, } dconfJSON, _ := json.Marshal(dconf) @@ -302,6 +315,15 @@ func (g *APKGGenerator) createNoteTypeConfig() map[string]interface{} { "did": g.deckID, "req": [][]interface{}{[]interface{}{0, "all", []int{0}}}, "vers": []int{}, + "tags": []string{}, + "latexPre": `\documentclass[12pt]{article} +\special{papersize=3in,5in} +\usepackage[utf8]{inputenc} +\usepackage{amssymb,amsmath} +\pagestyle{empty} +\setlength{\parindent}{0in} +\begin{document}`, + "latexPost": `\end{document}`, "flds": []map[string]interface{}{ { "name": "English", @@ -310,6 +332,7 @@ func (g *APKGGenerator) createNoteTypeConfig() map[string]interface{} { "rtl": false, "font": "Arial", "size": 20, + "media": []string{}, }, { "name": "Bulgarian", @@ -318,6 +341,7 @@ func (g *APKGGenerator) createNoteTypeConfig() map[string]interface{} { "rtl": false, "font": "Arial", "size": 20, + "media": []string{}, }, { "name": "Image", @@ -326,6 +350,7 @@ func (g *APKGGenerator) createNoteTypeConfig() map[string]interface{} { "rtl": false, "font": "Arial", "size": 20, + "media": []string{}, }, { "name": "Audio", @@ -334,6 +359,7 @@ func (g *APKGGenerator) createNoteTypeConfig() map[string]interface{} { "rtl": false, "font": "Arial", "size": 20, + "media": []string{}, }, { "name": "Notes", @@ -342,6 +368,7 @@ func (g *APKGGenerator) createNoteTypeConfig() map[string]interface{} { "rtl": false, "font": "Arial", "size": 16, + "media": []string{}, }, }, "tmpls": []map[string]interface{}{ @@ -350,6 +377,9 @@ func (g *APKGGenerator) createNoteTypeConfig() map[string]interface{} { "ord": 0, "qfmt": g.getFrontTemplate(), "afmt": g.getBackTemplate(), + "did": nil, + "bqfmt": "", + "bafmt": "", }, }, "css": g.getCSS(), |
