mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-08-04 08:28:36 +00:00
fix(webui): avoid parsing currency as math
This commit is contained in:
parent
ba0ba4749d
commit
9ceacc540c
@ -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
|
||||
|
||||
@ -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>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user