Skip to content

Commit a4b4dd3

Browse files
committed
feat: format Anki deck names to Title Case during sync
1 parent fba9de1 commit a4b4dd3

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

programs/anki.nix

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,15 @@ in
1919
echo -e "\033[1;34m--- Syncing Obsidian to Anki (API) ---\033[0m"
2020
for file in "$cards_dir"/*.md; do
2121
[ -e "$file" ] || continue
22-
local deck=$(basename "$file" .md)
22+
23+
# Get filename without extension
24+
local base_name=$(basename "$file" .md)
25+
26+
# Format deck name: kebab-case -> Title Case
27+
# Example: linux-basics -> Linux Basics
28+
local deck=$(echo "$base_name" | sed 's/-/ /g' | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) substr($i,2)}1')
29+
2330
echo "Processing: $deck"
24-
# We pass dummy DB path for compatibility
2531
anki-sync-internal "http://localhost:8765" "$deck" "$file"
2632
done
2733
echo -e "\033[1;32mSync Complete!\033[0m"

0 commit comments

Comments
 (0)