Closed yzy1228682367 closed 7 months ago
先简单做了一稿处理了下空格,后面有空了再完善。
/**
* Format Chinese annotations
* @author wakewon
* @usage in annotation menu
* @link https://github.com/windingwind/zotero-actions-tags/issues/265
* @see https://github.com/windingwind/zotero-actions-tags/issues/265
*/
if (!item) {
return;
}
return await EditAnnotation(item);
async function EditAnnotation(annotationItem) {
if (!annotationItem.isAnnotation()) {
return "Not an annotation item";
}
annotationItem.annotationText = await FormatText(annotationItem.annotationText);
return `Success`;
}
async function FormatText(text) {
// Remove spaces between Chinese characters, but keep spaces between English letters and digits.
return text.replace(/\s+(?=[^a-zA-Z0-9])/g, "");
}
感谢大佬!太牛了!
Is there an existing issue for this?
Environment
Describe the feature request
Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 感谢开发action&tag!自动化省了很多功夫。请问可否利用action&tag实现添加注释以后,自动去除注释内容中的空格以及乱码呢?
Why do you need this feature? A clear and concise description of why you need this feature. pdf中的中文文本有时空格很多,即使一行内没有空格,换行也会造成空格。目前可以利用快捷指令、quicker等工具选中文本以后去除空格,但是是否可以利用action&tag的功能实现全自动去除空格呢?感谢开发者~
Describe the solution you'd like
The solution you'd like A clear and concise description of what you want to happen.
Alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Anything else?
以下脚本(利用ChatGPT生成的)或许可以提供参考,主要功能是:第一,去除除了英文间的空格外的所有空格;第二,去除所有换行符,除了这个换行符前有“。”;第三,所有全角字符转为半角字符;第四,补全标点符号。
` function run(input, parameters) { // 第一个脚本内容 var inputText1 = String(input[0]);
}
function toHalfWidth(str) { return str.split('').map(function(char) { var code = char.charCodeAt(0);
}