Skip to content

Commit f3dc422

Browse files
committed
优化了context
1 parent fdbe254 commit f3dc422

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@
55
例如:"/root/hello/world.md"中的卡片会自动同步到"root::hello::world"中
66
2. 把id修改为block链接的形式,从而实现anki直接跳转到obsidian markdown文件对应的block
77
![图 1](images/5913712e835c128fdc7a12c0c0c1caa006ac7d47bf85a3a9f6c5970e37a0a948.png)
8-
8+
3. 优化了content的内容,路径和标题加在最前面,以换行分割,后面有一行分割线和卡片具体内容区分
99
# 本项目使用方法
1010
将main.js和manifes.json文件替换obsidian to anki中的main.js manifes.json
1111
在插件设置中,开启设置,并重启obsidian
1212
具体的使用方法可以参考[Obsidian_to_Anki](https://github.com/Pseudonium/Obsidian_to_Anki)
1313

14+
原来的正则表达式`(?<!<!--)`改为`(?<!<!--)(?<!\^ID-)`即可正常使用blockid
15+
16+
# todo
17+
优化加入上下文的格式,支持链接
18+
优化数学公式的转化,保证`\$``}}`能够正常显示
19+
20+
1421
# tip
1522
填空题存在问题,可能会匹配bookxnote和latex公式,请使用"((?:.+\n)*(?:.*{{c.*)(?:\n(?:^.{1,3}$|^.{4}(?<!<!--).*))*)",
1623
并只使用{{c\d:: text }}格式的填空题

data.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@
4242
"问答题(同时生成翻转的卡片)": "正面",
4343
"问答题(输入答案)": "正面"
4444
},
45-
"CONTEXT_FIELDS": {},
45+
"CONTEXT_FIELDS": {
46+
"Cloze ALL": "文字",
47+
"问答题": "正面"
48+
},
4649
"FOLDER_DECKS": {
4750
"未命名": "",
4851
"第一个文件夹": "",
@@ -118,7 +121,8 @@
118121
"未命名.md": "d41d8cd98f00b204e9800998ecf8427e",
119122
"norcx'anki'test/挖空测试.md": "08d3f20ea7d3869cf4e63b8ad32533ae",
120123
"未命名 1 1.md": "166ac5eb16bb207e951f3c68aa1f4943",
121-
"一次添加成功测试.md": "988168da191b9968488324f0f79360fb"
124+
"一次添加成功测试.md": "988168da191b9968488324f0f79360fb",
125+
"anki测试2.md": "f3eb9c8c9f9f8de8933c605fb1776a99"
122126
},
123127
"fields_dict": {
124128
"Basic": [

src/file.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ abstract class AbstractFile {
192192
}
193193
let result_arr: string[] = [result]
194194
result_arr.push(...heading_strs)
195-
return result_arr.join(" > ")
195+
return "<br>"+result_arr.join("<br>")+"<br>"+"<hr>"
196196
}
197197

198198
abstract writeIDs(): void

src/note.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ abstract class AbstractNote {
101101
}
102102
if (context) {
103103
const context_field = data.context_fields[this.note_type]
104-
template["fields"][context_field] += context
104+
template["fields"][context_field] = context + template["fields"][context_field]
105105
}
106106
if (data.add_obs_tags) {
107107
for (let key in template["fields"]) {
@@ -308,7 +308,7 @@ export class RegexNote {
308308
}
309309
if (context) {
310310
const context_field = data.context_fields[this.note_type]
311-
template["fields"][context_field] += context
311+
template["fields"][context_field] = context + template["fields"][context_field]
312312
}
313313
if (this.note_type.includes("Cloze") && !(note_has_clozes(template))) {
314314
this.identifier = CLOZE_ERROR //An error code that says "don't add this note!"

0 commit comments

Comments
 (0)