Skip to content

Commit 1b17491

Browse files
committed
fix: codeplaceholder formats
1 parent 1992982 commit 1b17491

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

.changeset/silver-kings-burn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"lingo.dev": patch
3+
---
4+
5+
inline code placeholder format

packages/cli/src/cli/loaders/mdx2/code-placeholder.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import createMdxCodePlaceholderLoader from "./code-placeholder";
33
import dedent from "dedent";
44
import { md5 } from "../../utils/md5";
55

6-
const PLACEHOLDER_REGEX = /---CODE_PLACEHOLDER_[0-9a-f]+---/g;
6+
const PLACEHOLDER_REGEX = /---CODE-PLACEHOLDER-[0-9a-f]+---/g;
77

88
const sampleContent = dedent`
99
Paragraph with some code:
@@ -20,7 +20,7 @@ describe("MDX Code Placeholder Loader", () => {
2020
it("should replace fenced code with placeholder on pull", async () => {
2121
const result = await loader.pull("en", sampleContent);
2222
const hash = md5('```js\nconsole.log("foo");\n```');
23-
const expected = `Paragraph with some code:\n\n---CODE_PLACEHOLDER_${hash}---`;
23+
const expected = `Paragraph with some code:\n\n---CODE-PLACEHOLDER-${hash}---`;
2424
expect(result.trim()).toBe(expected);
2525
});
2626

@@ -282,7 +282,7 @@ describe("MDX Code Placeholder Loader", () => {
282282
const md = "This is some `inline()` code.";
283283
const pulled = await loader.pull("en", md);
284284
const hash = md5("`inline()`");
285-
const expected = `This is some ---INLINE_CODE_PLACEHOLDER_${hash}--- code.`;
285+
const expected = `This is some ---INLINE-CODE-PLACEHOLDER-${hash}--- code.`;
286286
expect(pulled).toBe(expected);
287287
});
288288

packages/cli/src/cli/loaders/mdx2/code-placeholder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function extractCodePlaceholders(content: string): {
5353
for (const match of codeBlockMatches) {
5454
const codeBlock = match[0];
5555
const codeBlockHash = md5(codeBlock);
56-
const placeholder = `---CODE_PLACEHOLDER_${codeBlockHash}---`;
56+
const placeholder = `---CODE-PLACEHOLDER-${codeBlockHash}---`;
5757

5858
codePlaceholders[placeholder] = codeBlock;
5959

@@ -67,7 +67,7 @@ function extractCodePlaceholders(content: string): {
6767
for (const match of inlineCodeMatches) {
6868
const inlineCode = match[0];
6969
const inlineCodeHash = md5(inlineCode);
70-
const placeholder = `---INLINE_CODE_PLACEHOLDER_${inlineCodeHash}---`;
70+
const placeholder = `---INLINE-CODE-PLACEHOLDER-${inlineCodeHash}---`;
7171

7272
codePlaceholders[placeholder] = inlineCode;
7373

0 commit comments

Comments
 (0)