fix(webui): avoid parsing currency as math

This commit is contained in:
Xubin Ren 2026-07-27 21:22:23 +08:00
parent ba0ba4749d
commit 9ceacc540c
2 changed files with 15 additions and 2 deletions

View File

@ -14,7 +14,6 @@ const CARET = 94;
const UNDERSCORE = 95;
const EQUALS = 61;
const PLUS = 43;
const SLASH = 47;
const LESS_THAN = 60;
const GREATER_THAN = 62;
const LEFT_BRACE = 123;
@ -71,7 +70,6 @@ function isMathSignal(code: Code): boolean {
|| code === UNDERSCORE
|| code === EQUALS
|| code === PLUS
|| code === SLASH
|| code === LESS_THAN
|| code === GREATER_THAN
|| code === LEFT_BRACE

View File

@ -530,6 +530,21 @@ describe("MarkdownTextRenderer", () => {
expect(container.querySelector(".katex")).toBeNull();
});
it("keeps currency rates and later totals out of one inline math span", () => {
const { container } = render(
<MarkdownTextRenderer>
{
"费用预估为 **$0.10/5秒720p**,在余额内。我选择做一条 **8秒、16:9、带自然环境音** 的电影感梦幻片,预计约 **$0.16**,现在开始生成。"
}
</MarkdownTextRenderer>,
);
expect(container.querySelector(".katex")).toBeNull();
expect(container).toHaveTextContent("$0.10/5秒720p");
expect(container).toHaveTextContent("$0.16");
expect(container.querySelectorAll("strong")).toHaveLength(3);
});
it("renders guarded single-dollar inline math", () => {
const { container } = render(
<MarkdownTextRenderer>