UserScript:整形
code:script.js
scrapbox.PopupMenu.addButton({
title: 'format',
onClick: text => text.split('\n').map(function(line) {
return line.replace(/^\s*/g, s => s.replace(/\s/g, '\t'))
.replace(/ /g, '')
.replace(/ぁ-ん|ァ-ヴ゙/g, s => String.fromCharCode(s.charCodeAt(0) + 1)) .replace(/A-Za-z0-9/g, s => String.fromCharCode(s.charCodeAt(0) - 0xFEE0)) .replace('(', '(')
.replace(')', ')')
.replace(/\S\(/g, s => s.charAt(0) + ()
.replace(/\)\S/g, s => ') ' + s.charAt(1))
.replace(/\S.*/g, s => s.charAt(0) + ' ' + s.slice(1))
.replace(/.*\S/g, s => s.slice(0, -1) + ' ' + s.slice(-1))
}).join('\n')
})
UserScript.icon
https://img.shields.io/badge/JavaScript-UserScript_整形-F7DF1E.svg?logo=javascript&style=for-the-badge