Obsidian2Anki

参考资料

Obsidian_to_Anki 插件教程

Anki 插件设置

1
2
3
4
5
6
7
8
9
10
11
{
"apiKey": null,
"apiLogPath": null,
"webBindAddress": "127.0.0.1",
"webBindPort": 8765,
"webCorsOrigin": "http://localhost",
"webCorsOriginList": [
"http://localhost",
+ "app://obsidian.md"
]
}

修改完之后如下:

1
2
3
4
5
6
7
8
9
10
11
{
"apiKey": null,
"apiLogPath": null,
"webBindAddress": "127.0.0.1",
"webBindPort": 8765,
"webCorsOrigin": "http://localhost",
"webCorsOriginList": [
"http://localhost",
"app://obsidian.md"
]
}

Ob 笔记设置

笔记开头声明牌组:TARGET DECK: Test

普通卡 Neuracache

正则表达式:

1
((?:[^\n][\n]?)+) #flashcard ?\n*((?:\n(?:^.{1,3}$|^.{4}(?<!<!--).*))+)

参考资料:Neuracache flashcard style · Pseudonium/Obsidian_to_Anki Wiki · GitHub

卡片语法示例

1
2
3
4
TARGET DECK: Test

卡片正面内容 #flashcard
卡片背面内容

如下,若添加进 Anki 成功的话,会自动在卡片的下方添加上一个 html 注释

1
2
3
4
5
TARGET DECK: Test

卡片正面内容 #flashcard
卡片背面内容
<!--ID: 1691487007086-->

如果想要清除 Anki 中的卡片,在 ID 上一行添加 DELETE

1
2
3
这是卡片正面 #flashcard
this is the back of the card

  • DELETE 需要大写,同步之后,Anki 中对应的卡片就被自动删除了,Ob 中的笔记还在,只是将这条笔记下方的 ID 被删除了(也就是说下次同步时,还会自动往 Anki 中添加这条笔记)
  • 如果 Anki 中删除了笔记,而 Ob 中没有删除的话,那么同步 Ob 时,也不会往 Anki 中添加卡片了,因为这条笔记下面的 ID 还没有被删除

挖空卡 Cloze

正则表达式:

1
((?:.+\n)*(?:.*{.*)(?:\n(?:^.{1,3}$|^.{4}(?<!<!--).*))*)

参考资料:Cloze Paragraph style · Pseudonium/Obsidian_to_Anki Wiki · GitHub

注意:将正则表达式粘贴到 Cloze 类型的模板当中

高亮挖空卡

正则表达式:

1
((?:.+\n)*(?:.*==.*)(?:\n(?:^.{1,3}$|^.{4}(?<!<!--).*))*)

参考资料:Cloze Paragraph style · Pseudonium/Obsidian_to_Anki Wiki · GitHub

1
this is the ==highlight== note

注意:如果是需要开启 Highlight-cloze style,那么需要同时打开 CurlyCloze 和 CurlyCloze - Highlights to Cloze 两关开关