Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"rehype-raw": "^7.0.0",
"rehype-sanitize": "^6.0.0",
"remark-breaks": "^4.0.0",
"remark-cjk-friendly": "^2.3.1",
"remark-gfm": "^4.0.1",
"tailwind-merge": "^3.4.0",
"zustand": "^5.0.11"
Expand Down
17 changes: 17 additions & 0 deletions apps/web/src/components/ChatMarkdown.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,23 @@ describe("hasMarkdownFilePrimaryAction", () => {
});
});

describe("ChatMarkdown emphasis", () => {
it.each([false, true])(
"renders bold text ending in CJK punctuation with lineBreaks=%s",
(lineBreaks) => {
const text = ["**中文**中文", "**中文:**中文", "**中文。**中文", "**中文,**中文"].join(
"\n",
);
const html = renderToStaticMarkup(
<ChatMarkdown cwd="/tmp/project" text={text} lineBreaks={lineBreaks} />,
);

expect(html.match(/<strong>中文(?:[:。,])?<\/strong>中文/g)).toHaveLength(4);
expect(html).not.toContain("**");
},
);
});

describe("ChatMarkdown file option chips", () => {
it("keeps the fallback button text selectable", () => {
const html = renderToStaticMarkup(
Expand Down
3 changes: 3 additions & 0 deletions apps/web/src/components/ChatMarkdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import { defaultUrlTransform } from "react-markdown";
import rehypeRaw from "rehype-raw";
import rehypeSanitize, { defaultSchema } from "rehype-sanitize";
import remarkBreaks from "remark-breaks";
import remarkCjkFriendly from "remark-cjk-friendly";
import remarkGfm from "remark-gfm";
import { remarkGithubAlerts } from "../markdown-github-alerts";
import {
Expand Down Expand Up @@ -374,6 +375,7 @@ const CHAT_MARKDOWN_REMARK_PLUGINS = [
remarkGithubAlerts,
remarkNormalizeListItemIndentation,
remarkCodexDirectives,
remarkCjkFriendly,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium components/ChatMarkdown.tsx:378

CJK-adjacent strikethrough such as ~~中文。~~中文 still uses GFM's non-CJK delimiter rules and can render the delimiters literally. Adding only remarkCjkFriendly does not install the required remark-cjk-friendly-gfm-strikethrough companion while remarkGfm remains enabled; add that plugin to the remark pipeline.

🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/web/src/components/ChatMarkdown.tsx around line 378:

CJK-adjacent strikethrough such as `~~中文。~~中文` still uses GFM's non-CJK delimiter rules and can render the delimiters literally. Adding only `remarkCjkFriendly` does not install the required `remark-cjk-friendly-gfm-strikethrough` companion while `remarkGfm` remains enabled; add that plugin to the remark pipeline.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Extend CJK emphasis handling to mobile

When these strings are displayed in the mobile chat, this change only affects the web/desktop ReactMarkdown pipeline. I checked the iOS path: ThreadFeed.tsx sends messages to SelectableMarkdownText, which parses them with the vendored MD4C parser in SelectableMarkdownText.ios.tsx:46-50; that parser leaves the three punctuation-ending cases as literal **中文:**, **中文。**, and **中文,**. Add equivalent CJK-aware normalization or parser behavior, with coverage, to the mobile renderer so remote mobile users receive the same fix.

AGENTS.md reference: AGENTS.md:L67-L70

Useful? React with 👍 / 👎.

remarkPreserveCodeMeta,
remarkNormalizeLinksAndTagInlineCode,
] satisfies NonNullable<ReactMarkdownOptions["remarkPlugins"]>;
Expand All @@ -383,6 +385,7 @@ const CHAT_MARKDOWN_REMARK_PLUGINS_WITH_BREAKS = [
remarkGithubAlerts,
remarkNormalizeListItemIndentation,
remarkCodexDirectives,
remarkCjkFriendly,
remarkBreaks,
remarkPreserveCodeMeta,
remarkNormalizeLinksAndTagInlineCode,
Expand Down
81 changes: 81 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading