mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-08-01 19:06:01 +00:00
fix(frontend): preserve single tildes in markdown (#4245)
This commit is contained in:
parent
756eac0d1a
commit
693507870c
@ -12,11 +12,13 @@ const katexOptions = {
|
|||||||
strict: false,
|
strict: false,
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
const sharedRemarkPlugins = [
|
||||||
|
[remarkGfm, { singleTilde: false }],
|
||||||
|
[remarkMath, { singleDollarTextMath: true }],
|
||||||
|
] as StreamdownProps["remarkPlugins"];
|
||||||
|
|
||||||
export const streamdownPlugins = {
|
export const streamdownPlugins = {
|
||||||
remarkPlugins: [
|
remarkPlugins: sharedRemarkPlugins,
|
||||||
remarkGfm,
|
|
||||||
[remarkMath, { singleDollarTextMath: true }],
|
|
||||||
] as StreamdownProps["remarkPlugins"],
|
|
||||||
rehypePlugins: [
|
rehypePlugins: [
|
||||||
rehypeRaw,
|
rehypeRaw,
|
||||||
[rehypeKatex, katexOptions],
|
[rehypeKatex, katexOptions],
|
||||||
@ -24,10 +26,7 @@ export const streamdownPlugins = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const streamdownPluginsWithWordAnimation = {
|
export const streamdownPluginsWithWordAnimation = {
|
||||||
remarkPlugins: [
|
remarkPlugins: sharedRemarkPlugins,
|
||||||
remarkGfm,
|
|
||||||
[remarkMath, { singleDollarTextMath: true }],
|
|
||||||
] as StreamdownProps["remarkPlugins"],
|
|
||||||
rehypePlugins: [
|
rehypePlugins: [
|
||||||
[rehypeKatex, katexOptions],
|
[rehypeKatex, katexOptions],
|
||||||
rehypeSplitWordsIntoSpans,
|
rehypeSplitWordsIntoSpans,
|
||||||
|
|||||||
@ -83,3 +83,18 @@ describe("MarkdownContent streaming code blocks", () => {
|
|||||||
expect(html).toContain("data-streaming-code-block");
|
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 { expect, test } from "@rstest/core";
|
||||||
import rehypeRaw from "rehype-raw";
|
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", () => {
|
test("streamdownPlugins includes rehypeRaw", () => {
|
||||||
expect(streamdownPlugins.rehypePlugins).toContain(rehypeRaw);
|
expect(streamdownPlugins.rehypePlugins).toContain(rehypeRaw);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user