redleafnew / zotero-javascripts

Some JavaScripts used in Zotero to batch process
GNU General Public License v3.0
240 stars 40 forks source link

移除摘要中的多余换行 #5

Closed nkh0472 closed 7 months ago

nkh0472 commented 7 months ago

该脚本已进行测试。

zoteroPane = Zotero.getActiveZoteroPane();
items = zoteroPane.getSelectedItems();
for (item of items) {
var originalAbstract = item.getField('abstractNote').trim(); 
//将abstractNote换为extra则可以处理'其他'栏的内容
modifiedAbstract = originalAbstract.replace(/\n{2,}/g, '\n');
 item.setField('abstractNote', modifiedAbstract);
//如果前面换了extra,这里一定也要替换
 await item.saveTx();
}
return "摘要中的多余换行已删除!";
redleafnew commented 7 months ago

可以提交个PR image