看了好多obsidian和zotero联动的视频和教程,终于还是下手了。
obsidian和zotero之所有能够完美联动,很大程度上建立在这两个软件都有这活跃的第三方插件市场,只要肯花功夫挖掘,我相信是能玩出花来的。
网上的多数联动是基于Better BibTex(zotero)、Zotero Obsidian Citations(zotero)和BibNotes Formatter(obsidian)这三个插件的,但是在将笔记导入obsidian后,如果zotero有数据的更新,则需要重新将笔记导入到obsidian中,而本文将通过Bibnotes Formatter(obsidian)、zotero-better-bibtex(zotero)和MarkDBConnect(zotero)这三款插件实现obsidian和zotero的同步更新,梦幻联动(妈妈再也不用担心我的学习了)。
Ob仓库/.obsidian/plugins
中(.obsidian是隐藏文件夹),重启obsidian即可。打开zotero,点击文件——>导出文献库(整个zotero文献库)
选择导出格式为”BetterBibTeX JSON“
选择”导出笔记“和”Keep updated“(导出文件会使JSON文件很大,因此不勾选,为在添加/删除/修改条目后自动更新导出的库,需要勾选”Keep updated“)
将json文件放在obsidian中创建zotero笔记文件夹下(没有多大,所以不用担心内存问题),在Better BibTeX的设置中可以查看和更改json的路径
第一个是json文件路劲,第二个是笔记保存路径(注意:都是相对路径)
# {{title}}## Metadata
- **CiteKey**: {{citekey}}- **Type**: {{itemType}}- **Title**: {{title}}, - **Author**: {{author}}, - **Year**: {{year}} ;
- **Journal**: {{publicationTitle}},
- **Pages**: {{pages}}
- **Publisher**: {{publisher}},
- **Location**: {{place}},
- **DOI**: {{DOI}}
------## Files and Links
- **Url**: [Open online]({{url}})
- **zotero entry**: {{localLibrary}}
- **open pdf**: {{file}}- **Keywords**: {{keywordsAll}}## Abstract
{{abstractNote}}----## Comments
{{UserNotes}}----## Extracted Annotations
{{PDFNotes}}
****## Summary## Research Objective(s)## Background / Problem Statement## Method(s)## Evaluation## Conclusion## Notes
Bibnotes Formatter插件默认使用电脑自带的PDF阅读器打开PDF文件,因此需要对插件做一定的修改。打开插件文件中的main.js文件,找到其中的createLocalFileLink()函数,用下面的代码替换
function createLocalFileLink(reference2) {if (reference2.attachments.length == 0)return "{{localFile}}";const filesList = [];for (let attachmentindex = 0; attachmentindex < reference2.attachments.length; attachmentindex++) {if (reference2.attachments[attachmentindex].itemType !== "attachment")continue;// if (reference2.attachments[attachmentindex].path == void 0) {// reference2.attachments[attachmentindex].path = "";// }// const attachmentPathCorrected = reference2.attachments[attachmentindex].path.replaceAll(" ", "%20");// const selectedfile = "[" + reference2.attachments[attachmentindex].title + "](file://" + attachmentPathCorrected + ")";if (reference2.attachments[attachmentindex].uri == void 0) {reference2.attachments[attachmentindex].uri = "";}const selectedfileUri = reference2.attachments[attachmentindex].uriconst attachmentKey = selectedfileUri.split('/')[selectedfileUri.split('/').length - 1]selectedfile = "[" + reference2.attachments[attachmentindex].title + "](zotero://select/library/items/" + attachmentKey + ")";if (reference2.attachments[attachmentindex].title.endsWith('pdf')) {selectedfile = selectedfile.replaceAll("zotero://select/","zotero://open-pdf/");}filesList.push(selectedfile);}const filesListString = filesList.join("; ");return filesListString;
}
替换效果如下:
下载插件
在官网下载.xpi文件
安装插件
与zotero-better-bibtex插件的安装方法一样,这里不再赘述。
配置插件
打开zotero,点击工具——>MarkDBConnect Preferences,进入配置页面,填写Bibnotes Formatter文献笔记的保存路径(也就是obsidian的文献笔记路径)
BibNotes Formatter: Create/Update Literature Note
,然后选择想要阅读的文献即可BibNotes Formatter: Update Library
生成/更新自从上一次执行此命令以来,在zotero中修改的所有笔记。
如果第一次选择此命令,插件将为导入所有条目创建/更新文献信息。
BibNotes Formatter: Create/Update Literature Note
选择文献并生成对应的文献笔记。如果笔记已经存在,其内容将被更新,不会被覆盖。第一项是为文献库中的所有文献创建笔记(慎点)
至此zotero和Obsidian的联动就完成了,可以很方便地在两个软件中进行双向链接
参考:https://blog.csdn.net/qq_43309940/article/details/125150487