From b717f6d6ffa63641741cc13e4aad47ce7382e594 Mon Sep 17 00:00:00 2001 From: kabo2468 <28654659+kabo2468@users.noreply.github.com> Date: Thu, 17 Nov 2022 09:34:23 +0900 Subject: [PATCH] fix: don't nyaize quoted text --- .../backend/src/models/repositories/note.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/models/repositories/note.ts b/packages/backend/src/models/repositories/note.ts index 882cfdd318..ce589e1738 100644 --- a/packages/backend/src/models/repositories/note.ts +++ b/packages/backend/src/models/repositories/note.ts @@ -265,12 +265,22 @@ export const NoteRepository = db.getRepository(Note).extend({ if (packed.user.isCat && packed.text) { const tokens = packed.text ? mfm.parse(packed.text) : []; - mfm.inspect(tokens, (node) => { - if (node.type === "text") { - // TODO: quoteなtextはskip + function nyaizeNode(node: mfm.MfmNode) { + if (node.type === "quote") + return; + if (node.type === "text") node.props.text = nyaize(node.props.text); + + if (node.children) { + for (const child of node.children) { + nyaizeNode(child); + } } - }); + } + + for (const node of tokens) + nyaizeNode(node); + packed.text = mfm.toString(tokens); }