Skip to content

Instantly share code, notes, and snippets.

@ciaranchen
Created December 5, 2023 09:11
Show Gist options
  • Save ciaranchen/ad5cc47fd465f40ed68c4b30d3470605 to your computer and use it in GitHub Desktop.
Save ciaranchen/ad5cc47fd465f40ed68c4b30d3470605 to your computer and use it in GitHub Desktop.
Markdown ZotSelect

Markdown ZotSelect

这个文件主要用于从Zotero中复制出Markdown格式的文献引用。

  1. 打开Zotero数据文件夹(可在 Zotero首选项 -> 高级 -> 数据存储位置 中查看),将 Markdown ZotSelect.js 文件放置在translators文件夹中。
  2. 重启Zotero,可以看到多出了一种导出格式 Markdown ZotSelect。
  3. 在 Zotero首选项 -> 导出 -> 导出格式 中选择 Markdown ZotSelect 导出格式,则可以通过Ctrl+Shift+C 复制Markdown超链接样式的文献链接了。
{
"translatorID": "2de2b1a5-5725-494c-9224-5781cdf9b7ef",
"label": "Markdown ZotSelect",
"creator": "ciaranchen",
"target": "md",
"minVersion": "3.0",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 2,
"lastUpdated": "2021-09-21 07:46:51"
}
function doExport() {
// code is edited from https://gist.github.com/nschneid/3134386
var item;
while (item = Zotero.nextItem()) {
let url = 'zotero://select/items/';
var library_id = item.libraryID ? item.libraryID : 0;
var titleS = (item.title) ? item.title.replace(/&/g, '&').replace(/"/g, '"') : "(no title)";
var pubTitleS = (item.publicationTitle) ? item.publicationTitle.replace(/&/g, '&').replace(/"/g, '"') : "";
if (!pubTitleS && item.type) pubTitleS = '[' + item.type + ']';
url += library_id.toString() + item.key.toString();
let title = titleS + ' ' + ((item.conferenceName) ? item.conferenceName : pubTitleS);
Zotero.write(`[${title}](${url})`);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment