@@ -70,6 +70,14 @@ function yamlQuote(value: string): string {
7070 return value ;
7171}
7272
73+ /**
74+ * Escape MDX expression delimiters in plain prose so generated docs don't
75+ * evaluate `{ ... }` fragments as JavaScript at runtime.
76+ */
77+ function escapeMdxText ( value : string ) : string {
78+ return value . replace ( / [ { } ] / gu, '\\$&' ) ;
79+ }
80+
7381function renderList ( values : readonly string [ ] ) : string {
7482 if ( values . length === 0 ) return '- None' ;
7583 return values . map ( ( value ) => `- \`${ value } \`` ) . join ( '\n' ) ;
@@ -606,15 +614,17 @@ function renderOperationPage(operation: ContractOperationSnapshot, $defs: Defs):
606614 const title = operation . operationId ;
607615 const metadata = operation . metadata ;
608616 const description = OPERATION_DESCRIPTION_MAP [ operation . operationId ] ;
617+ const escapedDescription = escapeMdxText ( description ) ;
609618 const expectedResult = OPERATION_EXPECTED_RESULT_MAP [ operation . operationId ] ;
619+ const escapedExpectedResult = escapeMdxText ( expectedResult ) ;
610620
611621 const inputFields = renderFieldSections ( operation . schemas . input , $defs ) ;
612622 const outputFields = renderFieldSections ( operation . schemas . output , $defs ) ;
613623
614624 const inputExample = generateExample ( operation . schemas . input , $defs ) ;
615625 const outputExample = generateExample ( operation . schemas . output , $defs ) ;
616626 const stepOpsSection = renderStepOpsSection ( operation ) ;
617- const expectedResultSection = `${ expectedResult } ${ stepOpsSection ? `\n\n${ stepOpsSection } ` : '' } ` ;
627+ const expectedResultSection = `${ escapedExpectedResult } ${ stepOpsSection ? `\n\n${ stepOpsSection } ` : '' } ` ;
618628
619629 // -- Build raw-schema accordion blocks --
620630 const rawSchemaBlocks : string [ ] = [ ] ;
@@ -639,7 +649,7 @@ ${GENERATED_MARKER}
639649
640650## Summary
641651
642- ${ description }
652+ ${ escapedDescription }
643653
644654- Operation ID: \`${ operation . operationId } \`
645655- API member path: \`${ formatMemberPath ( operation . memberPath ) } \`
0 commit comments