SYAK:同步 SiYuan 内容块到 Anki, 自动更新, 自动删除
如果觉得有帮助, 麻烦点个 Star⭐
⚠ 初次使用请提前备份 Anki, 以免数据误删!
Prerequisite
- Anki 需要安装 AnkiConnect 插件, code 为
2055492159, 默认端口8765 - 支持 Python 3.9 以上版本
- SiYuan 默认端口为
6806 - 同步时, 保持 SiYuan 和 Anki 同时运行
Install
pip install -U syak
Usage
-
新建一个
card 文档块, 名字支持前后缀, 例如@card -
在需要制卡的内容块后面引用
card 文档块 -
制卡内容块为某个容器块下的叶子块时, 卡片正面为制卡内容块, 背面为整个容器块
-
制卡内容块为文档块下的叶子块时, 卡片正面为制卡内容块, 背面为空
-
运行命令
syak -p SiYuan数据根路径(data目录的上一级) 即可同步 -
运行周期任务
syak -p SiYuan数据根路径(data目录的上一级) -i (seconds), 例如每 5 分钟运行一次syak -p SiYuan数据根路径(data目录的上一级) -i 300 -
后台运行
- Linux&macOS
nohup syak -p SiYuan数据根路径(data目录的上一级) -i (seconds) & - Windows
start /b syak -p SiYuan数据根路径(data目录的上一级) -i (seconds)
- Linux&macOS
-
指定 deck 层级:
syak -p SiYuan数据根路径(data目录的上一级) --custom_deck 笔记本名/指定层级- 例如: 原始层级为
notebook/daily/2022/2022-12-28, 如果不想创建2022 和2022-12-08 两个 child deck, 可以使用syak -p SiYuan数据根路径(data目录的上一级) --custom_deck notebook/daily
- 例如: 原始层级为
-
查看更多选项运行
syak -h
Demo
Feature
- 添加 SiYuan URL 跳转链接
- 自动更新, SiYuan 更新内容块后, Anki 自动更新
- 自动删除, 删除
card 引用块, Anki 自动删除 - 根据文档块层级自动建立 deck 层级
- 支持 media 文件
- 自动删除 empty deck
- 同步完成时, 发送同步信息给 SiYuan, 停留 5s
Not Support (currently)
- Close
- 代码块语法高亮
- 超级块未适配
More
-
macOS 用户如果遇到同步耗时较长的问题, 可以参考:
-
FooSoft Productions - Anki-Connect
Starting with Mac OS X Mavericks, a feature named App Nap has been introduced to the operating system. This feature causes certain applications which are open (but not visible) to be placed in a suspended state. As this behavior causes Anki-Connect to stop working while you have another window in the foreground, App Nap should be disabled for Anki:
-
Start the Terminal application.
-
Execute the following commands in the terminal window:
defaults write net.ankiweb.dtop NSAppSleepDisabled -bool true defaults write net.ichi2.anki NSAppSleepDisabled -bool true defaults write org.qt-project.Qt.QtWebEngineCore NSAppSleepDisabled -bool true -
Restart Anki.
-
-
Changelog
-
更新到 0.1.8 🎉 🎉 🎉
升级:
pip install -U syak-
支持自定义 deck 层级
使用方式:
syak -p SiYuan数据根路径(data目录的上一级) --custom_deck 笔记本名/指定层级, 例如: 原始层级为notebook/daily/2022/2022-12-28, 如果不想创建2022 和2022-12-08 两个 child deck, 可以使用syak -p SiYuan数据根路径(data目录的上一级) --custom_deck notebook/daily -
修复删除空行引起的错误格式
-
-
更新到 0.1.7 🎉 🎉 🎉
升级:
pip install -U syak-
增加周期任务
- 运行周期任务
syak -p SiYuan数据根路径(data目录的上一级) -i (seconds), 例如每 5 分钟运行一次syak -p SiYuan数据根路径(data目录的上一级) -i 300
- 运行周期任务
-
后台运行
- Linux&macOS
nohup syak -p SiYuan数据根路径(data目录的上一级) -i (seconds) & - Windows
start /b syak -p SiYuan数据根路径(data目录的上一级) -i (seconds) 未测试
- Linux&macOS
-
Release files for syak 0.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| syak-0.1.9.tar.gz | 9.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| syak-0.1.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.0 kB
Release files / syak-0.1.9.tar.gz
| Download URL | syak-0.1.9.tar.gz |
|---|---|
| Size | 9.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
34ae678dbae9c6fa757974ec63d479dd79a3903fe6e8fbc182884fbc7310b5b4
|
|
BLAKE2b-256 checksum How to use checksums |
93583194aae77f889b9f458de87fa0ae374442e3d83cb86d68118d0c8cf154b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.1 CPython/3.9.5 Darwin/21.6.0
|
Release files / syak-0.1.9-py3-none-any.whl
| Download URL | syak-0.1.9-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a99e85bcfb5bd3fb76f354b81c71c31ada00c3392faa326ad442191972e7fb3d
|
|
BLAKE2b-256 checksum How to use checksums |
436a749d9d9a4816d97a5105d6f18c353ee1148805d44a9a7c66f8c7d45abfef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.1 CPython/3.9.5 Darwin/21.6.0
|