Skip to content

Commit

Permalink
fix: fix calling tryRestoreRawText
Browse files Browse the repository at this point in the history
  • Loading branch information
DGCK81LNN committed Feb 16, 2024
1 parent bb54292 commit 49e7d45
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/plugins/lnnzhyz.tsx
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/xdi8.ts
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -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: " " })
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/xegoe.tsx
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down Expand Up @@ -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 })
Expand Down

0 comments on commit 49e7d45

Please sign in to comment.