Kindleの引用
kindleからコピーしてきた文章を変なスペース取り除いて見やすくするやつ
https://gyazo.com/e8e8d3a772a09ffa41ca8d4406cd38f2
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