/// @ 0.13.2
### {
name: "カラーコード"
version: "0.1.1"
author: "fuwa2003"
description: "ノートの中のカラーコードに色見本をつけます"
}
Plugin:register_note_view_interruptor(@(note){
let hex = "0123456789abcdef"
var s = ""
var t = note.text
for (let i, note.text.len) {
if (t.len <= 0) break
let x = t.index_of("#")
if (x < 0) {
s = `{s}{t}`
t = ""
break
}
s = `{s}{t.slice(0, x)}`
t = t.slice(x, t.len)
var jj = 0
for let j, 7 {
if t.len <= j+1 || !hex.incl(t.pick(j+1).lower()) {
jj = j
break
}
}
if jj == 3 || jj == 4 || jj == 6 {
let c = t.slice(1, jj+1)
t = t.slice(jj+1, t.len)
s = `{s}$[fg.color={c} ■]#{c}`
} else {
s = `{s}{t.pick(0)}`
t = t.slice(1, t.len)
}
}
note.text = s
note
})