Skip to content

fix: escape curly braces in docstring prose (MDX JSX parse failures)#45

Merged
zzstoatzz merged 1 commit into
mainfrom
fix/mdx-escape-braces
Jun 22, 2026
Merged

fix: escape curly braces in docstring prose (MDX JSX parse failures)#45
zzstoatzz merged 1 commit into
mainfrom
fix/mdx-escape-braces

Conversation

@zzstoatzz

Copy link
Copy Markdown
Owner

Found while regenerating Prefect's integration docs — Mintlify's MDX parser (mint broken-links) failed on generated files with "Unable to parse … expression in container".

Two related causes, both fixed here:

  1. Bare {...} in docstring prose (e.g. a dict example like {"python_params": [...]}) was emitted unescaped. MDX treats { as a JSX expression delimiter. escape_mdx_content now escapes {/}\{/\} outside code.
  2. Multi-line backtick spans were matched as inline code by the escaper, but MDX does not treat a backtick span wrapping across a newline as code — so braces inside still reached the parser. Inline code is now matched single-line only; multi-line content falls through to prose escaping.

Verified: regenerating Prefect's full integration docs and running npx mint broken-links"success no broken links found" (previously hard-failed). Regression tests added for all three cases (prose braces, braces preserved in real code, braces in a multi-line span).

🤖 Generated with Claude Code

… as JSX

Two related MDX parse failures in generated docs:

1. Bare `{...}` in docstring prose (e.g. a dict example) was passed through
   unescaped. MDX treats `{` as a JSX expression delimiter, so Mintlify failed
   with "Unable to parse ... Unexpected lazy line in expression in container".
   escape_mdx_content now escapes `{`/`}` (to `\{`/`\}`) outside code.

2. The inline-code pattern matched backtick spans across newlines. MDX does NOT
   treat a multi-line backtick span as code, so braces inside it still reached
   the parser unescaped. Inline code is now matched single-line only; multi-line
   backtick content falls through to the prose escaper.

Regression tests cover bare-brace prose, braces preserved inside real code
spans/fences, and braces inside a multi-line backtick span.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@zzstoatzz
zzstoatzz merged commit 08ccc23 into main Jun 22, 2026
@zzstoatzz
zzstoatzz deleted the fix/mdx-escape-braces branch June 22, 2026 18:34
zzstoatzz added a commit that referenced this pull request Jun 22, 2026
Reverts the brace-escaping added in 0.2.43/0.2.44. It degraded output
(turning backtick-wrapped inline code into backslash-escaped braces) and was
the wrong layer to address MDX parse issues. Restores formatter.py to its
pre-#45 state; the empty-module and navigation fixes from 0.2.40-0.2.42 are
unaffected.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant