mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-07-21 02:05:45 +00:00
fix(frontend): preserve single tildes in markdown (#4245)
This commit is contained in:
@@ -12,11 +12,13 @@ const katexOptions = {
|
||||
strict: false,
|
||||
} as const;
|
||||
|
||||
const sharedRemarkPlugins = [
|
||||
[remarkGfm, { singleTilde: false }],
|
||||
[remarkMath, { singleDollarTextMath: true }],
|
||||
] as StreamdownProps["remarkPlugins"];
|
||||
|
||||
export const streamdownPlugins = {
|
||||
remarkPlugins: [
|
||||
remarkGfm,
|
||||
[remarkMath, { singleDollarTextMath: true }],
|
||||
] as StreamdownProps["remarkPlugins"],
|
||||
remarkPlugins: sharedRemarkPlugins,
|
||||
rehypePlugins: [
|
||||
rehypeRaw,
|
||||
[rehypeKatex, katexOptions],
|
||||
@@ -24,10 +26,7 @@ export const streamdownPlugins = {
|
||||
};
|
||||
|
||||
export const streamdownPluginsWithWordAnimation = {
|
||||
remarkPlugins: [
|
||||
remarkGfm,
|
||||
[remarkMath, { singleDollarTextMath: true }],
|
||||
] as StreamdownProps["remarkPlugins"],
|
||||
remarkPlugins: sharedRemarkPlugins,
|
||||
rehypePlugins: [
|
||||
[rehypeKatex, katexOptions],
|
||||
rehypeSplitWordsIntoSpans,
|
||||
|
||||
@@ -83,3 +83,18 @@ describe("MarkdownContent streaming code blocks", () => {
|
||||
expect(html).toContain("data-streaming-code-block");
|
||||
});
|
||||
});
|
||||
|
||||
describe("MarkdownContent strikethrough", () => {
|
||||
it("preserves single tildes in temperature ranges", () => {
|
||||
const html = renderMarkdown("周六23~30℃;周日22~30℃", false);
|
||||
|
||||
expect(html).toContain("周六23~30℃;周日22~30℃");
|
||||
expect(html).not.toContain("<del>");
|
||||
});
|
||||
|
||||
it("continues to render double-tilde strikethrough", () => {
|
||||
const html = renderMarkdown("状态:~~已取消~~", false);
|
||||
|
||||
expect(html).toContain("<del>已取消</del>");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,21 @@
|
||||
import { expect, test } from "@rstest/core";
|
||||
import rehypeRaw from "rehype-raw";
|
||||
import remarkGfm from "remark-gfm";
|
||||
|
||||
import { reasoningPlugins, streamdownPlugins } from "@/core/streamdown/plugins";
|
||||
import {
|
||||
reasoningPlugins,
|
||||
streamdownPlugins,
|
||||
streamdownPluginsWithWordAnimation,
|
||||
} from "@/core/streamdown/plugins";
|
||||
|
||||
test("shared streamdown configs disable single-tilde strikethrough", () => {
|
||||
const expectedGfmPlugin = [remarkGfm, { singleTilde: false }];
|
||||
|
||||
expect(streamdownPlugins.remarkPlugins).toContainEqual(expectedGfmPlugin);
|
||||
expect(streamdownPluginsWithWordAnimation.remarkPlugins).toContainEqual(
|
||||
expectedGfmPlugin,
|
||||
);
|
||||
});
|
||||
|
||||
test("streamdownPlugins includes rehypeRaw", () => {
|
||||
expect(streamdownPlugins.rehypePlugins).toContain(rehypeRaw);
|
||||
|
||||
Reference in New Issue
Block a user