Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
6963b12
feat: add inka module structure and dependencies
sysid Oct 21, 2025
a2116c5
feat: implement MathJax inline math plugin
sysid Oct 21, 2025
ed922ed
feat: add block math and mixed math support to MathJax plugin
sysid Oct 21, 2025
69525e4
feat: implement domain models for Card trait, BasicCard and ClozeCard
sysid Oct 21, 2025
93bc5ed
feat: implement markdown section parser
sysid Oct 21, 2025
c105028
feat: implement card type detection and field parsing
sysid Oct 21, 2025
d9041f4
feat: implement cloze deletion syntax transformation
sysid Oct 22, 2025
b8ff08e
feat: implement markdown to HTML converter with MathJax
sysid Oct 22, 2025
16935b3
feat: implement file reader with ID preservation
sysid Oct 26, 2025
021b76a
feat: implement ID injection into markdown
sysid Oct 26, 2025
456d471
feat: implement file writer with formatting preservation
sysid Oct 26, 2025
d6eaba9
feat: implement note type finder for Basic and Cloze
sysid Oct 26, 2025
7d5549f
feat: implement create note methods for Basic and Cloze
sysid Oct 26, 2025
7fab689
feat: implement update note and duplicate detection
sysid Oct 26, 2025
fdac974
feat: implement image extraction from markdown
sysid Oct 26, 2025
a6fbd94
feat: implement media file copying to Anki collection
sysid Oct 26, 2025
4bf341f
feat: implement media path updating in HTML
sysid Oct 26, 2025
081b69f
feat: implement TOML config file support
sysid Oct 26, 2025
f5bf77e
feat: implement SHA256 hash-based change detection
sysid Oct 26, 2025
c2f0432
feat: implement hash cache persistence with JSON storage
sysid Oct 26, 2025
4da4e34
feat: implement CardCollector use case orchestration
sysid Oct 26, 2025
f6825bb
feat: add collect CLI subcommand with recursive directory scanning
sysid Oct 26, 2025
736af32
test: add end-to-end integration tests for collect command
sysid Oct 26, 2025
79f7176
docs: add sample markdown notes with format guide
sysid Oct 26, 2025
b8b152c
refactor: fix all clippy warnings
sysid Oct 26, 2025
ad380c3
feat: add media file conflict detection and --force flag
sysid Nov 2, 2025
9df773c
fix Anki fixture directory structure for manual tests
sysid Nov 2, 2025
8a4124a
feat: add hash cache integration and --full-sync flag
sysid Nov 2, 2025
b354bdc
feat: add --update-ids flag for missing ID recovery
sysid Nov 2, 2025
927c529
feat(collect): add error handling with --ignore-errors flag
sysid Nov 2, 2025
db13393
docs: improve help text and add collect command documentation
sysid Nov 2, 2025
0c860fd
Bump version: 0.4.0 → 1.0.0
sysid Nov 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.bumpversion]
current_version = "0.4.0"
current_version = "1.0.0"
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
serialize = ["{major}.{minor}.{patch}"]
search = "{current_version}"
Expand Down
1 change: 1 addition & 0 deletions .idea/anki.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 22 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,28 @@ ADMIN:: ## ##################################################################
.PHONY: init-env
init-env: ## init-env
@rm -fr ~/xxx/*
@mkdir -p ~/xxx
@mkdir -p "$(HOME)/xxx/ankiview-test/"
cp -r ankiview/tests/fixtures/test_collection/* "$(HOME)/xxx/ankiview-test/"
cp -v ankiview/examples/image-test.md.ori ankiview/examples/image-test.md
cp -v ./ankiview/tests/fixtures/munggoggo.png ./ankiview/examples/munggoggo.png

.PHONY: create-note
create-note: init-env ## create a note from markdown
# cargo run --bin ankiview -- -c "$(HOME)/xxx/ankiview-test/User 1/collection.anki2" view 1695797540371
~/dev/s/private/ankiview/ankiview/target/debug/ankiview -c "$(HOME)/xxx/ankiview-test/User 1/collection.anki2" collect ./ankiview/examples/image-test.md
~/dev/s/private/ankiview/ankiview/target/debug/ankiview -c "$(HOME)/xxx/ankiview-test/User 1/collection.anki2" list | grep 'This is an image test!'

@echo
@echo "---- Following test should fail ---"
@echo
cp ./ankiview/tests/fixtures/gh_activity.png ./ankiview/examples/munggoggo.png
~/dev/s/private/ankiview/ankiview/target/debug/ankiview -c "$(HOME)/xxx/ankiview-test/User 1/collection.anki2" collect ./ankiview/examples/image-test.md

.PHONY: anki
anki: ## anki
-pkill anki
# specify base folder with -b
open /Applications/Anki.app --args -b $(HOME)/xxx/ankiview-test

.PHONY: test
test: ## Run all tests (unit, integration, and doc tests) with debug logging
Expand Down
124 changes: 121 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ AnkiView is a command-line tool that lets you quickly view Anki notes directly f

## Features ✨

- View any note by its ID in your default browser
- Delete notes from your collection via CLI
- **View notes** - View any note by its ID in your default browser
- **Delete notes** - Delete notes from your collection via CLI
- **Import markdown** - Convert markdown flashcards to Anki notes
- **Smart updates** - Automatically track cards with ID comments
- **Media handling** - Import images from markdown files
- **Hash caching** - Skip unchanged files for fast re-imports
- Automatic collection file detection
- Support for multiple Anki profiles
- LaTeX math rendering support
Expand Down Expand Up @@ -69,6 +73,105 @@ ankiview -c /path/to/collection.anki2 delete 1234567890
ankiview -p "User 1" delete 1234567890
```

### Collect markdown cards

Import markdown flashcards into your Anki collection:

```bash
# Import a single file
ankiview collect notes.md

# Import a directory (non-recursive)
ankiview collect notes/

# Import recursively (all subdirectories)
ankiview collect -r notes/
```

**Markdown Format**

Basic cards (question and answer):
```markdown
---
Deck: Programming
Tags: rust basics

1. What is Rust?
> A systems programming language

2. What is Cargo?
> Rust's package manager
---
```

Cloze deletion cards:
```markdown
---
Deck: Programming

1. Rust provides {memory safety} without garbage collection.
2. The {{c1::borrow checker}} ensures {{c2::safe concurrency}}.
---
```

Cards with images:
```markdown
---
Deck: ComputerScience

1. What type of graph is this?
> ![Graph diagram](images/dag.png)
> A directed acyclic graph (DAG)
---
```

**How It Works**

1. AnkiView reads your markdown files
2. Creates or updates notes in Anki
3. Injects ID comments into your markdown for tracking
4. Copies media files to Anki's collection.media/

After the first run, your markdown will have ID comments:
```markdown
<!--ID:1686433857327-->
1. What is Rust?
> A systems programming language
```

This allows you to edit the content and re-run collect to update (not duplicate) the cards.

**Advanced Usage**

```bash
# Recover lost IDs by searching Anki
ankiview collect -u notes/

# Force rebuild (bypass cache)
ankiview collect -f notes/

# Overwrite existing media files
ankiview collect --force notes/

# Continue on errors, report at end
ankiview collect -i notes/

# Combine flags for batch processing
ankiview collect -ri notes/
```

**Flag Reference**

| Flag | Description |
|------|-------------|
| `-r, --recursive` | Process subdirectories |
| `--force` | Overwrite conflicting media files |
| `-i, --ignore-errors` | Continue processing on errors |
| `-f, --full-sync` | Bypass hash cache (force rebuild) |
| `-u, --update-ids` | Search Anki for existing notes by content |

**Performance Note:** AnkiView maintains a hash cache to skip unchanged files. Use `-f` to force processing all files.

### Debug logging

Enable debug logging for any command (global flags can appear before or after subcommand):
Expand Down Expand Up @@ -129,9 +232,24 @@ RUST_LOG=debug cargo test
- Verify the collection path

2. **"Failed to open Anki collection"**
- Make sure Anki isn't running
- Make sure Anki isn't running (required for all commands)
- Check file permissions

3. **"Different file with the same name already exists"** (collect command)
- Media file conflict detected
- Use `--force` flag to overwrite existing media files
- Or rename your image file to avoid conflict

4. **Duplicate cards created** (collect command)
- Ensure ID comments (`<!--ID:-->`) are preserved in markdown
- Use `--update-ids` flag to recover lost IDs
- Check that you didn't manually modify or remove ID comments

5. **Cards not updating** (collect command)
- File may be unchanged (check hash cache)
- Use `-f` flag to force rebuild
- Verify ID comments are correct and match Anki notes

## Contributing 🤝

Contributions are welcome! Please feel free to submit a Pull Request.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.0
1.0.0
Loading