yanki 0.2.4 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/cli.js +9 -9
- package/dist/lib/index.d.ts +6 -1
- package/dist/lib/index.js +1 -1
- package/dist/sync-fLBwTuxC.js +222 -0
- package/package.json +7 -4
- package/readme.md +23 -13
- package/dist/sync-ESy7H_HY.js +0 -304
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yanki",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "An ultra-simple CLI tool and TypeScript library for syncing Markdown to Anki flashcards.",
|
|
6
6
|
"repository": {
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"chalk": "^5.3.0",
|
|
58
58
|
"globby": "^14.0.1",
|
|
59
59
|
"rehype-mathjax": "^6.0.0",
|
|
60
|
+
"rehype-parse": "^9.0.0",
|
|
60
61
|
"yargs": "^17.7.2"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
|
@@ -64,6 +65,9 @@
|
|
|
64
65
|
"@shikijs/rehype": "^1.6.4",
|
|
65
66
|
"bumpp": "^9.4.1",
|
|
66
67
|
"deepmerge-ts": "^7.0.3",
|
|
68
|
+
"filenamify": "^6.0.0",
|
|
69
|
+
"hast-util-to-text": "^4.0.2",
|
|
70
|
+
"nanoid": "^5.0.7",
|
|
67
71
|
"path-browserify-esm": "^1.0.4",
|
|
68
72
|
"pkgroll": "^2.1.1",
|
|
69
73
|
"plur": "^5.1.0",
|
|
@@ -81,15 +85,14 @@
|
|
|
81
85
|
"remark-remove-comments": "^1.0.1",
|
|
82
86
|
"remark-wiki-link": "^2.0.1",
|
|
83
87
|
"sort-keys": "^5.0.0",
|
|
84
|
-
"
|
|
85
|
-
"tsx": "^4.15.3",
|
|
88
|
+
"tsx": "^4.15.4",
|
|
86
89
|
"type-fest": "^4.20.0",
|
|
87
90
|
"typescript": "^5.4.5",
|
|
88
91
|
"unified": "^11.0.4",
|
|
89
92
|
"unist-builder": "^4.0.0",
|
|
90
93
|
"unist-util-visit": "^5.0.0",
|
|
91
94
|
"untildify": "^5.0.0",
|
|
92
|
-
"vite": "^5.
|
|
95
|
+
"vite": "^5.3.0",
|
|
93
96
|
"vitest": "^1.6.0",
|
|
94
97
|
"yaml": "^2.4.5",
|
|
95
98
|
"yanki-connect": "^1.0.4"
|
package/readme.md
CHANGED
|
@@ -127,6 +127,14 @@ An extended palette of markdown syntax is available out of the box:
|
|
|
127
127
|
|
|
128
128
|
Yanki uses Anki's built-in CSS stylesheet to style cards by default, but it makes it simple to set a custom stylesheet for all of your Yanki-managed notes without having to go on a click-quest in the Anki user interface.
|
|
129
129
|
|
|
130
|
+
### Filename management
|
|
131
|
+
|
|
132
|
+
The "one Markdown file = one Anki note" can make for a lot of individual files, and thinking up and renaming files as content is revised can be tedious. So, if you want, Yanki can manage the names of your note files based on their content.
|
|
133
|
+
|
|
134
|
+
Yanki looks inside each note, and extracts either the text of the prompt (e.g. the front of the card in most cases), or the "response" (e.g. the back of the card in most cases) to use as the filename. Truncation, deduplication, and sanitization are all taken care of.
|
|
135
|
+
|
|
136
|
+
Edge cases are carefully managed to ensure that there's always _some kind_ of best-effort semantically valuable file name assigned.
|
|
137
|
+
|
|
130
138
|
## Markdown note types
|
|
131
139
|
|
|
132
140
|
Yanki automatically infers the _type_ of Note you'd like to create in Anki based on the presence or absence of certain element in your Markdown files.
|
|
@@ -300,17 +308,19 @@ yanki sync <directory> [options]
|
|
|
300
308
|
| ------------------- | ------------------------------------------------------------------------ | -------- |
|
|
301
309
|
| `directory` | The path to the local directory of Markdown files to sync. _(Required.)_ | `string` |
|
|
302
310
|
|
|
303
|
-
| Option
|
|
304
|
-
|
|
|
305
|
-
| `--dry-run`
|
|
306
|
-
| `--namespace`
|
|
307
|
-
| `--anki-connect`
|
|
308
|
-
| `--anki-auto-launch`
|
|
309
|
-
| `--anki-web`
|
|
310
|
-
| `--
|
|
311
|
-
| `--
|
|
312
|
-
| `--
|
|
313
|
-
| `--
|
|
311
|
+
| Option | Alias | Argument | Description | Type | Default |
|
|
312
|
+
| ----------------------- | ----- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | ------------------------- |
|
|
313
|
+
| `--dry-run` | `-d` | | Run without making any changes to the Anki database. See a report of what would have been done. | `boolean` | `false` |
|
|
314
|
+
| `--namespace` | `-n` | | Advanced option for managing multiple Yanki synchronization groups. Case insensitive. See the readme for more information. | `string` | `"Yanki"` |
|
|
315
|
+
| `--anki-connect` | | | Host and port of the Anki-Connect server. The default is usually fine. See the Anki-Connect documentation for more information. | `string` | `"http://127.0.0.1:8765"` |
|
|
316
|
+
| `--anki-auto-launch` | `-l` | | Attempt to open the Anki desktop app if it's not already running. (Experimental, macOS only.) | `boolean` | `false` |
|
|
317
|
+
| `--anki-web` | `-w` | | Automatically sync any changes to AnkiWeb after Yanki has finished syncing locally. If false, only local Anki data is updated and you must manually invoke a sync to AnkiWeb. This is the equivalent of pushing the "sync" button in the Anki app. | `boolean` | `true` |
|
|
318
|
+
| `--manage-filenames` | `-m` | | Rename local note files to match their content. Useful if you want to feel have semantically reasonable note file names without managing them by hand. The `"prompt"` option will attempt to create the filename based on the "front" of the card, while `"response"` will prioritize the "back", "Cloze", or "type in the answer" portions of the card. Truncation, sanitization, and deduplication are taken care of. | `string` | `"off"` |
|
|
319
|
+
| `--max-filename-length` | | `[number]` | If `manage-filenames` is enabled, this option specifies the maximum length of the filename in characters. | | `60` |
|
|
320
|
+
| `--json` | | | Output the sync report as JSON. | `boolean` | `false` |
|
|
321
|
+
| `--verbose` | | | Enable verbose logging. | `boolean` | `false` |
|
|
322
|
+
| `--help` | `-h` | | Show help | `boolean` | |
|
|
323
|
+
| `--version` | `-v` | | Show version number | `boolean` | |
|
|
314
324
|
|
|
315
325
|
#### Subcommand: `yanki list`
|
|
316
326
|
|
|
@@ -486,9 +496,9 @@ The Yanki TypeScript / JavaScript library is idempotent, so you can run it in a
|
|
|
486
496
|
|
|
487
497
|
There's one exception, the `syncFiles(...)` function, which by default relies on file system access to work.
|
|
488
498
|
|
|
489
|
-
To retain `syncFiles(...)`'s utility in a browser environment, has the optional arguments `readFile` and `
|
|
499
|
+
To retain `syncFiles(...)`'s utility in a browser environment, has the optional arguments `readFile`, `writeFile`, and `rename`, which are implemented by `node:fs/promises` by default in Node environments.
|
|
490
500
|
|
|
491
|
-
Running Yanki in a browser environment
|
|
501
|
+
Running Yanki in a browser environment requires implementing and passing `readFile`, `writeFile`, and `rename` implementations to `syncFiles(...)` that are suited to your particular use case. (A warning will be provided if you neglect to do so.)
|
|
492
502
|
|
|
493
503
|
The rest of the library should work fine in both contexts without special measures.
|
|
494
504
|
|