Skip to content

Commit

Permalink
优化了context
Browse files Browse the repository at this point in the history
  • Loading branch information
norcx committed Apr 28, 2024
1 parent fdbe254 commit f3dc422
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@
例如:"/root/hello/world.md"中的卡片会自动同步到"root::hello::world"中
2. 把id修改为block链接的形式,从而实现anki直接跳转到obsidian markdown文件对应的block
![图 1](images/5913712e835c128fdc7a12c0c0c1caa006ac7d47bf85a3a9f6c5970e37a0a948.png)

3. 优化了content的内容,路径和标题加在最前面,以换行分割,后面有一行分割线和卡片具体内容区分
# 本项目使用方法
将main.js和manifes.json文件替换obsidian to anki中的main.js manifes.json
在插件设置中,开启设置,并重启obsidian
具体的使用方法可以参考[Obsidian_to_Anki](https://github.com/Pseudonium/Obsidian_to_Anki)

原来的正则表达式`(?<!<!--)`改为`(?<!<!--)(?<!\^ID-)`即可正常使用blockid

# todo
优化加入上下文的格式,支持链接
优化数学公式的转化,保证`\$``}}`能够正常显示


# tip
填空题存在问题,可能会匹配bookxnote和latex公式,请使用"((?:.+\n)*(?:.*{{c.*)(?:\n(?:^.{1,3}$|^.{4}(?<!<!--).*))*)",
并只使用{{c\d:: text }}格式的填空题
Expand Down
8 changes: 6 additions & 2 deletions data.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
"问答题(同时生成翻转的卡片)": "正面",
"问答题(输入答案)": "正面"
},
"CONTEXT_FIELDS": {},
"CONTEXT_FIELDS": {
"Cloze ALL": "文字",
"问答题": "正面"
},
"FOLDER_DECKS": {
"未命名": "",
"第一个文件夹": "",
Expand Down Expand Up @@ -118,7 +121,8 @@
"未命名.md": "d41d8cd98f00b204e9800998ecf8427e",
"norcx'anki'test/挖空测试.md": "08d3f20ea7d3869cf4e63b8ad32533ae",
"未命名 1 1.md": "166ac5eb16bb207e951f3c68aa1f4943",
"一次添加成功测试.md": "988168da191b9968488324f0f79360fb"
"一次添加成功测试.md": "988168da191b9968488324f0f79360fb",
"anki测试2.md": "f3eb9c8c9f9f8de8933c605fb1776a99"
},
"fields_dict": {
"Basic": [
Expand Down
2 changes: 1 addition & 1 deletion src/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ abstract class AbstractFile {
}
let result_arr: string[] = [result]
result_arr.push(...heading_strs)
return result_arr.join(" > ")
return "<br>"+result_arr.join("<br>")+"<br>"+"<hr>"
}

abstract writeIDs(): void
Expand Down
4 changes: 2 additions & 2 deletions src/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ abstract class AbstractNote {
}
if (context) {
const context_field = data.context_fields[this.note_type]
template["fields"][context_field] += context
template["fields"][context_field] = context + template["fields"][context_field]
}
if (data.add_obs_tags) {
for (let key in template["fields"]) {
Expand Down Expand Up @@ -308,7 +308,7 @@ export class RegexNote {
}
if (context) {
const context_field = data.context_fields[this.note_type]
template["fields"][context_field] += context
template["fields"][context_field] = context + template["fields"][context_field]
}
if (this.note_type.includes("Cloze") && !(note_has_clozes(template))) {
this.identifier = CLOZE_ERROR //An error code that says "don't add this note!"
Expand Down

0 comments on commit f3dc422

Please sign in to comment.