From b451712dc2e4ec5089107a24ec2bacf940a42d95 Mon Sep 17 00:00:00 2001 From: littlefrontender Date: Tue, 5 May 2026 16:35:11 +0400 Subject: [PATCH] Revert "Merge pull request #63 from testomatio/feature/57" This reverts commit ca950e95ecfe1dbeb56d1b440d0e1db34a5d2b87, reversing changes made to fb8eba3f351566931cda411aea50924156ff5457. --- src/editor/customMarkdownConverter.test.ts | 84 ---------------------- src/editor/customMarkdownConverter.ts | 13 +--- 2 files changed, 2 insertions(+), 95 deletions(-) diff --git a/src/editor/customMarkdownConverter.test.ts b/src/editor/customMarkdownConverter.test.ts index 86eb1d9..fa4f713 100644 --- a/src/editor/customMarkdownConverter.test.ts +++ b/src/editor/customMarkdownConverter.test.ts @@ -2685,90 +2685,6 @@ describe("markdownToBlocks", () => { }, ]); }); - - it("preserves opening-fence content when it is not a clean language identifier", () => { - const markdown = [ - "```curl `http://localhost:3000/projects/classic-project/test/e1c1b38c/edit` \\", - "{{baseURL}}/endpoint?query_param_one=value_one&query_param_two=value_two", - "```", - ].join("\n"); - const blocks = markdownToBlocks(markdown); - expect(blocks).toEqual([ - { - type: "codeBlock", - props: { language: "" }, - content: [ - { - type: "text", - text: [ - "curl `http://localhost:3000/projects/classic-project/test/e1c1b38c/edit` \\", - "{{baseURL}}/endpoint?query_param_one=value_one&query_param_two=value_two", - ].join("\n"), - styles: {}, - }, - ], - children: [], - }, - ]); - }); - - it("round-trips an opening-fence-with-content code block to stable markdown", () => { - const markdown = [ - "```curl `http://localhost:3000/projects/classic-project/test/e1c1b38c/edit` \\", - "{{baseURL}}/endpoint?query_param_one=value_one&query_param_two=value_two", - "```", - ].join("\n"); - const blocks = markdownToBlocks(markdown); - const serialized = blocksToMarkdown(blocks as CustomEditorBlock[]); - expect(serialized).toBe( - [ - "```", - "curl `http://localhost:3000/projects/classic-project/test/e1c1b38c/edit` \\", - "{{baseURL}}/endpoint?query_param_one=value_one&query_param_two=value_two", - "```", - ].join("\n"), - ); - expect(markdownToBlocks(serialized)).toEqual(blocks); - }); - - it("preserves hyphenated language identifiers like shell-session", () => { - const markdown = ["```shell-session", "$ ls", "```"].join("\n"); - const blocks = markdownToBlocks(markdown); - expect(blocks).toEqual([ - { - type: "codeBlock", - props: { language: "shell-session" }, - content: [{ type: "text", text: "$ ls", styles: {} }], - children: [], - }, - ]); - }); - - it("preserves digit-prefixed language identifiers like 1c-enterprise", () => { - const markdown = ["```1c-enterprise", "code", "```"].join("\n"); - const blocks = markdownToBlocks(markdown); - expect(blocks).toEqual([ - { - type: "codeBlock", - props: { language: "1c-enterprise" }, - content: [{ type: "text", text: "code", styles: {} }], - children: [], - }, - ]); - }); - - it("sanitizes a malformed in-memory language prop on serialize", () => { - const blocks: CustomEditorBlock[] = [ - { - id: "1", - type: "codeBlock", - props: { ...baseProps, language: "curl http://x" } as any, - content: [{ type: "text", text: "body", styles: {} }] as any, - children: [], - }, - ]; - expect(blocksToMarkdown(blocks)).toBe(["```", "body", "```"].join("\n")); - }); }); describe("file block serialization", () => { diff --git a/src/editor/customMarkdownConverter.ts b/src/editor/customMarkdownConverter.ts index 725bdc0..7870787 100644 --- a/src/editor/customMarkdownConverter.ts +++ b/src/editor/customMarkdownConverter.ts @@ -334,8 +334,7 @@ function serializeBlock( return lines; } case "codeBlock": { - const rawLanguage = (block.props as any).language || ""; - const language = /[\s`]/.test(rawLanguage) ? "" : rawLanguage; + const language = (block.props as any).language || ""; const fence = "```" + language; const body = inlineContentToPlainText(block.content); lines.push(fence); @@ -1291,16 +1290,8 @@ function parseCodeBlock(lines: string[], index: number): { block: CustomPartialB }; } - const info = afterOpening.trim(); - let language = ""; + const language = afterOpening.trim(); const body: string[] = []; - if (info.length > 0) { - if (/[\s`]/.test(info)) { - body.push(afterOpening); - } else { - language = info; - } - } let next = index + 1; while (next < lines.length && !lines[next].startsWith("```") ) { body.push(lines[next]);