Add syntax recheck guard
This commit is contained in:
parent
8c7e56207b
commit
e61c84056c
1 changed files with 42 additions and 29 deletions
|
@ -377,6 +377,18 @@ export const pack = async (
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
if ((() => { // Recheck syntax
|
||||||
|
const match = _note.text && _note.text.match(/<\/?!?nya>/ig) || [];
|
||||||
|
const stack: string[] = [];
|
||||||
|
for (const tag of [...match]
|
||||||
|
.map(x => x.toLocaleLowerCase()))
|
||||||
|
if (tag.includes('/')) {
|
||||||
|
if (stack.pop() !== tag.replace('/', ''))
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
stack.push(tag);
|
||||||
|
return !stack.length;
|
||||||
|
})()) {
|
||||||
const nyamap: { [x: string]: string } = {
|
const nyamap: { [x: string]: string } = {
|
||||||
//#region nyaize: ja-JP
|
//#region nyaize: ja-JP
|
||||||
'な': 'にゃ',
|
'な': 'にゃ',
|
||||||
|
@ -416,6 +428,7 @@ export const pack = async (
|
||||||
_note.text += stack[0] && nyamap[head] || head;
|
_note.text += stack[0] && nyamap[head] || head;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!opts.skipHide) {
|
if (!opts.skipHide) {
|
||||||
await hideNote(_note, meId);
|
await hideNote(_note, meId);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue