@@ -149,7 +149,7 @@ import { SourceOwner } from "./source-owner.ts";
149149import { SchemaValidationError , validateProps , validateReturnValue } from "./validate.ts" ;
150150import { isJsonObject , parseJson } from "./json.ts" ;
151151import { healSegment } from "./heal.ts" ;
152- import { scanSegments } from "./scanner.ts" ;
152+ import { scanSegments , splitTextFences } from "./scanner.ts" ;
153153import { declareChildAnswers , expandAnswers , strayAnswerError } from "./answers.ts" ;
154154import { DeclarationScan } from "./declaration-scan.ts" ;
155155import { RESERVED_STRUCTURAL } from "./structural.ts" ;
@@ -995,23 +995,27 @@ function* expandListSegments(
995995 // Heal incomplete markdown constructs at segment boundaries (spec §2.3)
996996 // Runs synchronously — no yield, no journal entry
997997 const healed = healSegment ( segment . content ) ;
998- const protectedEscapes = healed . replaceAll ( "\\{" , ESCAPED_BRACE_PLACEHOLDER ) ;
999998 const textEvalEnv = yield * env ;
1000999 const textProps =
10011000 textEvalEnv !== undefined && "props" in textEvalEnv . values
10021001 ? textEvalEnv . values . props
10031002 : parentProps ;
1004- // Interpolate {meta.key} and {props.key} — runtime, no journal
1005- const interpolated = interpolate ( protectedEscapes , parentMeta , textProps ) ;
1006- // Interpolate bare {name} refs from eval bindings (spec §6.4/§6.6).
1007- // Runs after meta/props interpolation so component contract takes
1008- // precedence. Only runs when a binding environment is in scope.
1009- const final = textEvalEnv
1010- ? interpolateEvalBindings ( interpolated , textEvalEnv . values )
1011- : interpolated ;
1003+ const final = splitTextFences ( segment , healed )
1004+ . map ( ( { content, passive } ) => {
1005+ if ( passive ) {
1006+ return content ;
1007+ }
1008+ const protectedEscapes = content . replaceAll ( "\\{" , ESCAPED_BRACE_PLACEHOLDER ) ;
1009+ const interpolated = interpolate ( protectedEscapes , parentMeta , textProps ) ;
1010+ const bound = textEvalEnv
1011+ ? interpolateEvalBindings ( interpolated , textEvalEnv . values )
1012+ : interpolated ;
1013+ return bound . replaceAll ( ESCAPED_BRACE_PLACEHOLDER , "{" ) ;
1014+ } )
1015+ . join ( "" ) ;
10121016 result . push ( {
10131017 type : "text" ,
1014- content : final . replaceAll ( ESCAPED_BRACE_PLACEHOLDER , "{" ) ,
1018+ content : final ,
10151019 } ) ;
10161020 break ;
10171021 }
0 commit comments