Skip to content

Comments

fix: upd code placeholder#1760

Merged
cherkanovart merged 4 commits intomainfrom
fix/upd-code-palceholder
Feb 13, 2026
Merged

fix: upd code placeholder#1760
cherkanovart merged 4 commits intomainfrom
fix/upd-code-palceholder

Conversation

@vrcprl
Copy link
Contributor

@vrcprl vrcprl commented Jan 22, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Fixed MDX code placeholder handling to ensure proper processing of code blocks in documentation.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 12, 2026

📝 Walkthrough

Walkthrough

This pull request fixes MDX code placeholder generation and detection by changing the placeholder format from HTML-comment style delimiters to a simpler token format with a trailing suffix and truncating MD5 hashes to 16 characters. The implementation and corresponding tests are updated to reflect this format change.

Changes

Cohort / File(s) Summary
Changeset
.changeset/polite-jobs-knock.md
New changeset file declaring a patch version bump for "lingo.dev" with description "fix MDX code placeholder".
MDX Code Placeholder
packages/cli/src/cli/loaders/mdx2/code-placeholder.ts, packages/cli/src/cli/loaders/mdx2/code-placeholder.spec.ts
Updated placeholder format from { /* CODE_PLACEHOLDER_<hash> */ } to CODE_PLACEHOLDER_<hash>_END for code blocks and from { /* INLINE_CODE_PLACEHOLDER_<hash> */ } to INLINE_CODE_PLACEHOLDER_<hash>_END for inline code. Hash generation truncated to 16 characters via .slice(0, 16). Test assertions updated to match new placeholder format and expectations.

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A placeholder fix hops along the way,
Hash truncated, format saved the day,
No more comments cluttering the code,
Just tokens clean upon the road! 🐰✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Description check ⚠️ Warning No pull request description was provided; the template sections for Summary, Changes, Testing, Visuals, and Checklist are all missing. Add a complete PR description following the template, including a summary of changes, key modifications, test coverage details, and confirmation of the changeset.
Title check ❓ Inconclusive The title 'fix: upd code placeholder' is vague and uses abbreviated language ('upd' instead of 'update') that doesn't clearly convey the specific nature of the code placeholder fix. Use a more descriptive title such as 'fix: update MDX code placeholder format' to clearly communicate the main change.
✅ Passed checks (1 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/upd-code-palceholder

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@packages/cli/src/cli/loaders/mdx2/code-placeholder.spec.ts`:
- Around line 607-611: Replace the stale assertion that checks for the old block
comment placeholder with one that asserts the new placeholder format is not
present: update the second expect that currently reads against /\{\/\*
CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/ to instead assert
pushedResult.not.toMatch(/CODE_PLACEHOLDER_[0-9a-f]+_END/); locate the assertion
referencing pushedResult in code-placeholder.spec.ts and swap the regex
accordingly so the test verifies the new placeholder format.
- Around line 641-645: The test contains a stale assertion checking for the old
block-comment format (/\{\/\* CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/) against the
variable pushedResult; replace that assertion with one that ensures the new
end-marker format is not present, e.g. change the second expect to verify
pushedResult does not match /CODE_PLACEHOLDER_[0-9a-f]+_END/ so the test asserts
absence of the new CODE_PLACEHOLDER_<hash>_END pattern (refer to pushedResult
and the spec in code-placeholder.spec.ts).
🧹 Nitpick comments (1)
packages/cli/src/cli/loaders/mdx2/code-placeholder.spec.ts (1)

872-874: Stale comment referencing old {/* */} format.

The comment on line 874 still references the old {/* */} placeholder format. Should be updated to reflect the new _END suffix format.

Comment on lines 607 to 611
expect(pushedResult).not.toMatch(
/\{\/\* INLINE_CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/,
/INLINE_CODE_PLACEHOLDER_[0-9a-f]+_END/,
);
expect(pushedResult).not.toMatch(/\{\/\* CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/);

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Stale assertion checking old placeholder format that no longer exists.

Line 610 still checks for the old {/* CODE_PLACEHOLDER_... */} format. Since code-block placeholders now use CODE_PLACEHOLDER_<hash>_END, this assertion will always pass trivially and doesn't verify anything useful. It should check the new format instead:

Suggested fix
       expect(pushedResult).not.toMatch(
         /INLINE_CODE_PLACEHOLDER_[0-9a-f]+_END/,
       );
-      expect(pushedResult).not.toMatch(/\{\/\* CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/);
+      expect(pushedResult).not.toMatch(/CODE_PLACEHOLDER_[0-9a-f]+_END/);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
expect(pushedResult).not.toMatch(
/\{\/\* INLINE_CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/,
/INLINE_CODE_PLACEHOLDER_[0-9a-f]+_END/,
);
expect(pushedResult).not.toMatch(/\{\/\* CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/);
expect(pushedResult).not.toMatch(
/INLINE_CODE_PLACEHOLDER_[0-9a-f]+_END/,
);
expect(pushedResult).not.toMatch(/CODE_PLACEHOLDER_[0-9a-f]+_END/);
🤖 Prompt for AI Agents
In `@packages/cli/src/cli/loaders/mdx2/code-placeholder.spec.ts` around lines 607
- 611, Replace the stale assertion that checks for the old block comment
placeholder with one that asserts the new placeholder format is not present:
update the second expect that currently reads against /\{\/\*
CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/ to instead assert
pushedResult.not.toMatch(/CODE_PLACEHOLDER_[0-9a-f]+_END/); locate the assertion
referencing pushedResult in code-placeholder.spec.ts and swap the regex
accordingly so the test verifies the new placeholder format.

Comment on lines 641 to 645
expect(pushedResult).not.toMatch(
/\{\/\* INLINE_CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/,
/INLINE_CODE_PLACEHOLDER_[0-9a-f]+_END/,
);
expect(pushedResult).not.toMatch(/\{\/\* CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/);
expect(pushedResult).toContain("`الحصول_على_البيانات()`");
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Same stale old-format assertion as above.

Line 644 has the same issue — checking for the defunct {/* ... */} format instead of the new CODE_PLACEHOLDER_<hash>_END format.

Suggested fix
       expect(pushedResult).not.toMatch(
         /INLINE_CODE_PLACEHOLDER_[0-9a-f]+_END/,
       );
-      expect(pushedResult).not.toMatch(/\{\/\* CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/);
+      expect(pushedResult).not.toMatch(/CODE_PLACEHOLDER_[0-9a-f]+_END/);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
expect(pushedResult).not.toMatch(
/\{\/\* INLINE_CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/,
/INLINE_CODE_PLACEHOLDER_[0-9a-f]+_END/,
);
expect(pushedResult).not.toMatch(/\{\/\* CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/);
expect(pushedResult).toContain("`الحصول_على_البيانات()`");
expect(pushedResult).not.toMatch(
/INLINE_CODE_PLACEHOLDER_[0-9a-f]+_END/,
);
expect(pushedResult).not.toMatch(/CODE_PLACEHOLDER_[0-9a-f]+_END/);
expect(pushedResult).toContain("`الحصول_على_البيانات()`");
🤖 Prompt for AI Agents
In `@packages/cli/src/cli/loaders/mdx2/code-placeholder.spec.ts` around lines 641
- 645, The test contains a stale assertion checking for the old block-comment
format (/\{\/\* CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/) against the variable
pushedResult; replace that assertion with one that ensures the new end-marker
format is not present, e.g. change the second expect to verify pushedResult does
not match /CODE_PLACEHOLDER_[0-9a-f]+_END/ so the test asserts absence of the
new CODE_PLACEHOLDER_<hash>_END pattern (refer to pushedResult and the spec in
code-placeholder.spec.ts).

@cherkanovart cherkanovart merged commit c68b34b into main Feb 13, 2026
5 checks passed
@cherkanovart cherkanovart deleted the fix/upd-code-palceholder branch February 13, 2026 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants