Skip to content

Commit

Permalink
完成了上下文的优化
Browse files Browse the repository at this point in the history
  • Loading branch information
norcx committed Apr 28, 2024
1 parent f3dc422 commit ae62e76
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
例如:"/root/hello/world.md"中的卡片会自动同步到"root::hello::world"中
2. 把id修改为block链接的形式,从而实现anki直接跳转到obsidian markdown文件对应的block
![图 1](images/5913712e835c128fdc7a12c0c0c1caa006ac7d47bf85a3a9f6c5970e37a0a948.png)
3. 优化了content的内容,路径和标题加在最前面,以换行分割,后面有一行分割线和卡片具体内容区分
3. 优化了context的内容,路径和标题加在最前面,以换行分割,后面有一行分割线和卡片具体内容区分。标题中如果有链接可以转化成功。
# 本项目使用方法
将main.js和manifes.json文件替换obsidian to anki中的main.js manifes.json
在插件设置中,开启设置,并重启obsidian
Expand All @@ -14,7 +14,6 @@
原来的正则表达式`(?<!<!--)`改为`(?<!<!--)(?<!\^ID-)`即可正常使用blockid

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


Expand Down
2 changes: 1 addition & 1 deletion data.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"norcx'anki'test/挖空测试.md": "08d3f20ea7d3869cf4e63b8ad32533ae",
"未命名 1 1.md": "166ac5eb16bb207e951f3c68aa1f4943",
"一次添加成功测试.md": "988168da191b9968488324f0f79360fb",
"anki测试2.md": "f3eb9c8c9f9f8de8933c605fb1776a99"
"anki测试2.md": "c7752cfda45e6276a954db1c154f8791"
},
"fields_dict": {
"Basic": [
Expand Down
8 changes: 7 additions & 1 deletion src/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,13 @@ abstract class AbstractFile {
}
let heading_strs: string[] = []
for (let contextHeading of currentContext) {
heading_strs.push(contextHeading.heading)
let convertedHeading = contextHeading.heading
// 修改:添加Markdown链接转换为HTML链接的代码
const markdownLinkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;
convertedHeading = contextHeading.heading.replace(markdownLinkRegex, '<a href="$2">$1</a>');
const mathRegex = /\$(.+?)\$/g;
convertedHeading = convertedHeading.replace(mathRegex, '\\($1\\)');
heading_strs.push(convertedHeading)
}
let result_arr: string[] = [result]
result_arr.push(...heading_strs)
Expand Down

0 comments on commit ae62e76

Please sign in to comment.