Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(markdown): keep single tildes literal in chat #23181

Closedonly21mil(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/23181/headopened View on GitHub

Showing 2 changed files with 27 additions and 3 deletions.

x
0 of 2 viewed, 2 left
25 additions and 1 deletionpackages/shared/src/markdownPipeline.test.tsModified
View file
@@ -2,7 +2,11 @@
import { unified } from "unified";
import remarkParse from "remark-parse";
import remarkRehype from "remark-rehype";
-import { CHAT_MARKDOWN_REHYPE_PLUGINS, CHAT_MARKDOWN_REMARK_PLUGINS } from "./markdownPipeline.ts";
+import {
+ CHAT_MARKDOWN_REHYPE_PLUGINS,
+ CHAT_MARKDOWN_REMARK_PLUGINS,
+ CHAT_MARKDOWN_REMARK_PLUGINS_WITH_BREAKS,
+} from "./markdownPipeline.ts";
​
it("preserves in-app thread links through the shared Markdown sanitizer", () => {
const processor = unified()
@@ -77,3 +81,23 @@
expect(render("Built [![CI](/ci.svg)](/ci)\nand wrapped")).toBe("Built <img>\nand wrapped");
expect(render("Hard-wrapped\nprose")).toBe("Hard-wrapped\nprose");
});
+​
+it("keeps single tildes literal and strikes only double-tilde pairs, like the rich composer", () => {
+ type Node = { type: string; value?: string; tagName?: string; children?: Node[] };
+ const text = (node: Node): string =>
+ node.type === "text"
+ ? (node.value ?? "")
+ : node.tagName === "del"
+ ? `<del>${(node.children ?? []).map(text).join("")}</del>`
+ : (node.children ?? []).map(text).join("");
+​
+ for (const plugins of [CHAT_MARKDOWN_REMARK_PLUGINS, CHAT_MARKDOWN_REMARK_PLUGINS_WITH_BREAKS]) {
+ const processor = unified().use(remarkParse).use(plugins).use(remarkRehype);