From 49e7d453a71b9e5ad8a18c675c96b83995e982dd Mon Sep 17 00:00:00 2001 From: DGCK81LNN <54282183+DGCK81LNN@users.noreply.github.com> Date: Fri, 16 Feb 2024 19:54:25 +0800 Subject: [PATCH] fix: fix calling tryRestoreRawText --- src/plugins/lnnzhyz.tsx | 8 ++++---- src/plugins/xdi8.ts | 4 ++-- src/plugins/xegoe.tsx | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/plugins/lnnzhyz.tsx b/src/plugins/lnnzhyz.tsx index 7acedde..692d199 100644 --- a/src/plugins/lnnzhyz.tsx +++ b/src/plugins/lnnzhyz.tsx @@ -1,8 +1,8 @@ -import { Context, Schema, h } from "koishi" -import type {} from "@koishijs/plugin-help" import { compileMandarin, compileShidinn, draw } from "@dgck81lnn/lnnzhyz2svg" import { deserializeText, serializeText } from "@dgck81lnn/lnnzhyz2svg/notation" -import { stripTags, tryRestoreRawText } from "../utils" +import type { } from "@koishijs/plugin-help" +import { Context, Schema, h } from "koishi" +import { tryRestoreRawText } from "../utils" export const name = "lnnzhyz" export const inject = ["component:html"] @@ -47,7 +47,7 @@ export function apply(ctx: Context, config: Config) { cmd.option("type", "-n", { value: "notation", hidden: true }) cmd.action( async ({ options: { compile: compileOnly, type }, session, source }, text) => { - if (source) text = stripTags(tryRestoreRawText(text, source) || text) + if (source) text = tryRestoreRawText(text, source, true) if (compileOnly && type === "notation") return session.text(".cannot-compile-notation") diff --git a/src/plugins/xdi8.ts b/src/plugins/xdi8.ts index 6ef25da..1b0b0f4 100644 --- a/src/plugins/xdi8.ts +++ b/src/plugins/xdi8.ts @@ -1,7 +1,7 @@ import { Context, Schema, Session, h } from "koishi" import type { Alternation, TranscribeResult } from "xdi8-transcriber" import { getHx, getXh } from "../transcriber-manager" -import { ahoFixes, stripTags, tryRestoreRawText } from "../utils" +import { ahoFixes, tryRestoreRawText } from "../utils" export const name = "xdi8" @@ -117,7 +117,7 @@ export function apply(ctx: Context, config: Config) { showWarning: true, }) cmdXdi8.option("all", "-a").action(({ options, session, source }, text) => { - if (source) text = stripTags(tryRestoreRawText(text, source) || text) + if (source) text = tryRestoreRawText(text, source, true) text = text.replace(/[⁰¹²³⁴⁵⁶⁷⁸⁹]+/g, "") const hxResult = getHx().transcribe(text, { ziSeparator: " " }) diff --git a/src/plugins/xegoe.tsx b/src/plugins/xegoe.tsx index 2b73dd8..fcb95a6 100644 --- a/src/plugins/xegoe.tsx +++ b/src/plugins/xegoe.tsx @@ -1,7 +1,7 @@ import { Context, Schema, h } from "koishi" import { chatToXdPUA, type Alternation, type TranscribeResult } from "xdi8-transcriber" import { getHx, getXh } from "../transcriber-manager" -import { stripTags, tryRestoreRawText } from "../utils" +import { tryRestoreRawText } from "../utils" export const name = "xegoe" export const inject = ["component:html"] @@ -113,7 +113,7 @@ export function apply(ctx: Context, config: Config) { .option("all", "-a") .option("x2h", "-x") .action(({ options: { all, x2h }, session, source }, text) => { - if (source) text = stripTags(tryRestoreRawText(text, source) || text) + if (source) text = tryRestoreRawText(text, source, true) const result = (x2h ? xhTranscribe : hxTranscribe)(text) const visual = formatResult(result, x2h ? "x" : "h", { all })