[Share] Remove the bracketed portion of the comment|去除注释中的括号部分 #365
ProudBenzene
started this conversation in
Ideas
Replies: 1 comment
-
With the reference of wakewon's script, finally I figured out my Long Bracket Killer script here. If anyone meets the same brackets problem with me, you can try this. Only brackets with more than 8 words between them should be killed. /**
* Long Brackets Killer
* @author ProudBenzene
* @reference https://github.com/windingwind/zotero-actions-tags/discussions/269
* @usage Removing brackets and long text within brackets
* @link https://github.com/windingwind/zotero-actions-tags/discussions/365
* @see https://github.com/windingwind/zotero-actions-tags/discussions/365
*/
if (!item) return;
const topItem = Zotero.Items.getTopLevel([item])[0];
const formatLang = ["", "en", "en-US", "en_US", "zh", "zh-CN", "zh_CN"];
const lang = topItem.getField("language");
if (!formatLang.includes(lang)) return "[Action: Format Chinese Annotations] Skip due to language";
return await editAnnotation(item);
async function editAnnotation(annotationItem) {
if (!annotationItem.isAnnotation()) return "[Action: Format Chinese Annotations] Not an annotation item";
// if (!annotationItem.annotationText) return "[Action: Format Chinese Annotations] No text found in this annotation text"; // for annotationText 对高亮文本进行处理
if (!annotationItem.annotationComment) return "[Action: Format Chinese Annotations] No text found in this annotation comment";// for annotationComment 对注释进行处理
// annotationItem.annotationText = await formatText(annotationItem.annotationText); // for annotationText 对高亮文本进行处理
annotationItem.annotationComment = await formatText(annotationItem.annotationComment); // for annotationComment 对注释进行处理
return;
}
async function formatText(text) {
return text
.replace(/\(([^()]{9,})\)/g, '')
.replace(/([^()]{9,})/g, '')
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
希望可以去除Annotation 标注(Comment)中的括号部分。很多时候文献自身带有的行内引用,例如
(Calancie et al., 1998, 2001; Langeloo et al., 2003; Calancie and Molano, 2008)
,会占据大量的文本字数,它们就像插入文本的两把长刀一样会导致阅读Annotation标注的翻译时会感到非常隔断。因此希望可以有一个动作,一键去掉Annotation标注Comment评论中长于8个英文字符的括号内容(考虑到较短的括号内容可能是术语缩写或图表标记)。
我对JavaScript代码的撰写并不熟练,Zotero中运用的脚本我更加不会撰写,希望有大佬可以施以援手,解决这个文献阅读痛点!
I would like to remove the bracketed portion of the Annotation comment. Very often in-line references such as
(Calancie et al., 1998, 2001; Langeloo et al., 2003; Calancie and Molano, 2008)
take up a lot of text, and are like two long knives inserted into the text. Annotation translations can be very compartmentalized when read.Therefore, it is desirable to have an action that removes bracketed content longer than 8 English characters from Annotation annotated Comment comments with a single click (taking into account that shorter bracketed content may be terminology abbreviations or graphical markers).
I am not proficient in writing JavaScript code, nor do I know how to write the scripts used in Zotero. I hope there will be some experts out there who can lend a helping hand and solve this literature-reading pain point!
Beta Was this translation helpful? Give feedback.
All reactions