Fix critic.mdx rendering issue caused by embedded triple backticks#368
Fix critic.mdx rendering issue caused by embedded triple backticks#368
Conversation
The Python example file (34_critic_example.py) contains triple backticks inside a multi-line string (used to show example file content in the task prompt). When synced to the MDX documentation, these embedded backticks were closing the markdown code block prematurely, causing: - The content after the first embedded ``` to render as regular markdown - Repeated content appearing multiple times on the page - Broken page structure This fix: 1. Updates sync_code_blocks.py to escape embedded triple backticks by inserting zero-width spaces between them (```), which: - Prevents markdown parser from treating them as code block delimiters - Preserves visual appearance in the rendered code block 2. Updates comparison logic to handle both escaped and unescaped content 3. Fixes the critic.mdx file with properly escaped content Co-authored-by: openhands <openhands@all-hands.dev>
Updates code examples in documentation files to match current source files in the agent-sdk repository. Co-authored-by: openhands <openhands@all-hands.dev>
Local Verification ScreenshotHere's a screenshot from the local Mintlify dev server confirming the page now renders correctly: Key improvements visible:
The fix escapes embedded triple backticks in the Python source file using zero-width spaces, preventing the markdown parser from incorrectly treating them as code block delimiters. |
Local Verification ScreenshotHere's a screenshot from the local Mintlify dev server confirming the page renders correctly after the fix: Click to see screenshotThe screenshot shows:
Key fixes verified:
|
all-hands-bot
left a comment
There was a problem hiding this comment.
Taste Rating: 🟡 Acceptable - Pragmatic fix for a real problem, but the zero-width space hack has implications that need consideration.
Summary: The fix addresses the immediate rendering issue, but introduces invisible characters that could cause copy-paste problems for users. Consider the alternative approach suggested below.
|
@OpenHands can you fix the unresolved comments: #368 (review) |
|
I'm on it! xingyaoww can track my progress at all-hands.dev |
- Add comprehensive docstring explaining zero-width space tradeoff - Handle empty/falsy content in escape_embedded_backticks - Fix regex pattern to handle code blocks without trailing newlines - Simplify comparison logic with clearer variable names - Add unit tests for escape_embedded_backticks and related functions Co-authored-by: openhands <openhands@all-hands.dev>
SummaryI've successfully addressed all 4 unresolved review comments on PR #368. The changes have already been pushed to the Checklist of Review Comments Addressed
Files Changed
Actions Completed
The changes are concise and directly address the reviewer's feedback without any extraneous modifications. |
Summary of changes
Fixes the rendering issue on https://docs.openhands.dev/sdk/guides/critic where the page displayed repeated content like:
Root Cause
The Python example file (
34_critic_example.py) contains triple backticks inside a multi-line string (used to show example file content in the task prompt). When the sync script copied this content into the MDX documentation, these embedded backticks closed the markdown code block prematurely, causing:```to render as regular markdownChanges
.github/scripts/sync_code_blocks.py: Addedescape_embedded_backticks()function that inserts zero-width spaces between backticks (`) to prevent markdown parsing issues while preserving visual appearancesdk/guides/critic.mdx: Regenerated with properly escaped contentBonus: Also synced a few other documentation files with latest agent-sdk examples
Verification
Ran local Mintlify dev server and confirmed the critic page now renders correctly: