zotero-javascripts文章题目大小写转为每个单词首字母大写-
zoteroPane = Zotero.getActiveZoteroPane();
items = zoteroPane.getSelectedItems();
var result = "";
// 列出常见的介词
var prepositions = ["of", "in", "on", "and", "the", "with", "for", "to", "at", "by", "from"];
for (item of items) {
var title = item.getField('title');
result += " " + title + "\n";
var new_title = title.replace(/\b\w+\b/g, function (word) {
if (prepositions.includes(word.toLowerCase())) {
return word.toLowerCase();
} else {
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
}
});
result += "-> " + new_title + "\n\n";
// Do it at your own risk
item.setField('title', new_title);
await item.saveTx();
}
return result;
陈 林
2023年8月17日 上海 FDU
参考资料:
https://www.zotero.org/support/dev/client_coding/javascript_api
https://github.com/redleafnew/zotero-javascripts/blob/main/02change-the-item-title-to-sentence-case.js
https://chat.openai.com/