Last active
October 29, 2020 14:09
-
-
Save karasugawasu/90024d4f56370a8a76853591ef093ef2 to your computer and use it in GitHub Desktop.
長文自動折りたたみ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### { | |
name: "長文自動折りたたみ" | |
version: "0.0.4" | |
author: "@karasu_sue@misskey.krsgw-雛.com" | |
description: "長文自動折りたたみ 改行10個 or 400文字以上" | |
permissions: [] | |
} | |
$cwmark <- "" | |
@check(text, cwtext) { | |
? (text = _) { | |
<< no | |
} .? Core:not((cwtext = _)) { | |
<< no | |
} | |
$lfnum <- Arr:len(Str:split(text, Str:lf)) | |
? (lfnum < 10) { | |
? (Str:len(text) < 400) { | |
<< no | |
} | |
} | |
Str:index_of(text, Str:lf) | |
} | |
@createtext(cwnum, text) { | |
Str:slice(text, (cwnum + 1), (Str:len(text) + 1)) | |
} | |
@createcw(cwnum, text) { | |
`{Str:slice(text, 0, cwnum)}{cwmark}` | |
} | |
Plugin:register_note_view_interruptor(@(note) { | |
? Obj:has(note, "renote") { | |
? Core:not((note.text = _)) { | |
cwmark <- " (自動cw)" | |
} | |
#re = check(note.renote.text, note.renote.cw) | |
? (Core:type(re) = "num") { | |
note.renote.cw <- createcw(re, note.renote.text) | |
note.renote.text <- createtext(re, note.renote.text) | |
} | |
} | |
cwmark <- " <small>(自動cw)</small>" | |
#nom = check(note.text, note.cw) | |
? (Core:type(nom) = "num") { | |
note.cw <- createcw(nom, note.text) | |
note.text <- createtext(nom, note.text) | |
} | |
note | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment