@@ -1136,37 +1136,49 @@ const parseNodesWithFactory = <TNode extends StructuralNode | IndexedStructuralN
11361136 child . contentEndI = closeStart ;
11371137 return true ;
11381138 } ;
1139+
1140+ const hasEscapedFullCloseAtEof = ( frame : ParseFrame ) : boolean => {
1141+ if ( frame . inlineCloseToken !== endTag ) return false ;
1142+ const escapedEndTag = escapeChar + endTag ;
1143+ const escapedStart = frame . textEnd - escapedEndTag . length ;
1144+ return escapedStart >= frame . argStartI && frame . text . startsWith ( escapedEndTag , escapedStart ) ;
1145+ } ;
1146+
11391147 const tryFinalizeFrameAtEof = ( frame : ParseFrame ) : boolean => {
11401148 if ( frame . i < frame . textEnd ) return false ;
11411149
11421150 if ( frame . inlineCloseToken !== null ) {
1151+ const escapedFullCloseAtEof = hasEscapedFullCloseAtEof ( frame ) ;
11431152 // inline 帧走到文本末尾仍未关闭 → 未闭合错误
11441153 // 这里不要整段吞掉:只把 tag 头回退成普通文本,并把父帧 i 放回 argStart。
11451154 // 后续正文会继续在父帧里按正常字符流扫描,这是老版本错误恢复语义。
1146- emitError (
1147- tracker ,
1148- onError ,
1149- frame . implicitInlineShorthand ? "SHORTHAND_NOT_CLOSED" : "INLINE_NOT_CLOSED" ,
1150- frame . text ,
1151- frame . tagStartI ,
1152- frame . argStartI - frame . tagOpenPos ,
1153- emittedErrorKeys ,
1154- ) ;
1155+ if ( ! escapedFullCloseAtEof ) {
1156+ emitError (
1157+ tracker ,
1158+ onError ,
1159+ frame . implicitInlineShorthand ? "SHORTHAND_NOT_CLOSED" : "INLINE_NOT_CLOSED" ,
1160+ frame . text ,
1161+ frame . tagStartI ,
1162+ frame . argStartI - frame . tagOpenPos ,
1163+ emittedErrorKeys ,
1164+ ) ;
1165+ }
11551166 stack . pop ( ) ;
11561167 const parent = stack [ frame . parentIndex ] ;
1168+ const fallbackScanStart = escapedFullCloseAtEof ? frame . textEnd : frame . argStartI ;
11571169 const eofOwnership = resolveShorthandOwnership ( {
11581170 phase : "eof" ,
11591171 frame,
11601172 parent : parent ?? null ,
11611173 } ) ;
11621174 if ( eofOwnership === "defer-parent" ) {
1163- appendBuf ( parent , frame . tagStartI , frame . argStartI ) ;
1164- parent . i = frame . argStartI ;
1175+ appendBuf ( parent , frame . tagStartI , fallbackScanStart ) ;
1176+ parent . i = fallbackScanStart ;
11651177 return true ;
11661178 }
11671179
1168- appendBuf ( parent , frame . tagStartI , frame . argStartI ) ;
1169- parent . i = frame . argStartI ;
1180+ appendBuf ( parent , frame . tagStartI , fallbackScanStart ) ;
1181+ parent . i = fallbackScanStart ;
11701182 return true ;
11711183 }
11721184
0 commit comments