mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
fix: disable single-dollar math to prevent currency symbol text corruption
Set singleDollarTextMath: false in remarkMath config so that single $ signs (e.g. R$, US$, $100) are not treated as inline math delimiters. Math expressions still work with $$ syntax. Fixes #11648
This commit is contained in:
parent
ae09ee5a64
commit
1976a4b80e
2 changed files with 41 additions and 1 deletions
|
|
@ -308,7 +308,7 @@ const MarkdownBlock = memo(({ markdown }: MarkdownBlockProps) => {
|
|||
<ReactMarkdown
|
||||
remarkPlugins={[
|
||||
remarkGfm,
|
||||
remarkMath,
|
||||
[remarkMath, { singleDollarTextMath: false }],
|
||||
() => {
|
||||
return (tree: any) => {
|
||||
visit(tree, "code", (node: any) => {
|
||||
|
|
|
|||
|
|
@ -88,6 +88,46 @@ describe("MarkdownBlock", () => {
|
|||
expect(screen.getByText("Step three")).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it("should render currency symbols without text corruption", async () => {
|
||||
const markdown = "The price is R$100 or US$50."
|
||||
const { container } = render(<MarkdownBlock markdown={markdown} />)
|
||||
|
||||
await screen.findByText(/The price is/, { exact: false })
|
||||
|
||||
const paragraph = container.querySelector("p")
|
||||
expect(paragraph?.textContent).toBe("The price is R$100 or US$50.")
|
||||
|
||||
// Should not produce any math/katex elements
|
||||
const mathElements = container.querySelectorAll(".katex")
|
||||
expect(mathElements.length).toBe(0)
|
||||
})
|
||||
|
||||
it("should render double-dollar math expressions", async () => {
|
||||
const markdown = "The formula is $$x^2 + y^2 = z^2$$."
|
||||
const { container } = render(<MarkdownBlock markdown={markdown} />)
|
||||
|
||||
await screen.findByText(/The formula is/, { exact: false })
|
||||
|
||||
// Should render katex math
|
||||
const mathElements = container.querySelectorAll(".katex")
|
||||
expect(mathElements.length).toBeGreaterThan(0)
|
||||
})
|
||||
|
||||
it("should not treat single dollar signs as math delimiters", async () => {
|
||||
const markdown = "Cost: $50 to $100 range."
|
||||
const { container } = render(<MarkdownBlock markdown={markdown} />)
|
||||
|
||||
await screen.findByText(/Cost/, { exact: false })
|
||||
|
||||
const paragraph = container.querySelector("p")
|
||||
expect(paragraph?.textContent).toContain("$50")
|
||||
expect(paragraph?.textContent).toContain("$100")
|
||||
|
||||
// No math elements should be created from single-dollar text
|
||||
const mathElements = container.querySelectorAll(".katex")
|
||||
expect(mathElements.length).toBe(0)
|
||||
})
|
||||
|
||||
it("should render nested lists with proper hierarchy", async () => {
|
||||
const markdown = `Complex list:
|
||||
1. First level ordered
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue