Kindleの引用
/sukesan1984/Kindleの引用
code: script.js
scrapbox.PopupMenu.addButton({
title: 'kindle引用',
onClick: text => {
text = zenhan(text);
text = text.split(/\n/).map(line => line.normalize()
.replace(/((?<=^A-Za-z))(\s+)((?=A-Za-z))/g,'') // A あ
.replace(/((?<=A-Za-z))(\s+)((?=^A-Za-z))/g,'') // あ A
.replace(/((?<=^A-Za-z))(\s+)((?=^A-Za-z))/g,'')) // あ あ
.join('\n')
return text;
}
})
function zenhan(text) {
text = text.replace(/A-Za-z0-9/g, (s) => {
return String.fromCharCode(s.charCodeAt(0) - 65248);
});
//16進数の場合
text = text.replace(/A-Za-z0-9/g, (s) => {
return String.fromCharCode(s.charCodeAt(0) - 0xFEE0);
});
text = text.replace(/ /g,' ');
return text;
}
#UserScript