@@ -173,6 +173,42 @@ func TestEngine_Fix_BalancedNestedMarkers(t *testing.T) {
173173 assert .NotContains (t , result , "old outer" )
174174}
175175
176+ func TestEngine_Check_MalformedNestedStartMarker (t * testing.T ) {
177+ // A malformed nested start marker (missing ?>) should emit a
178+ // diagnostic without affecting depth tracking.
179+ src := "<?mock\n key: a\n ?>\n <?mock\n key: b\n <?/mock?>\n "
180+ f := newTestFile (t , "test.md" , src )
181+ d := & mockDirective {content : "" }
182+ e := NewEngine (d )
183+ diags := e .Check (f )
184+ found := false
185+ for _ , d := range diags {
186+ if strings .Contains (d .Message , "<?mock is missing closing ?>" ) {
187+ found = true
188+ }
189+ }
190+ assert .True (t , found ,
191+ "expected malformed nested start marker diagnostic, got %v" , diags )
192+ }
193+
194+ func TestEngine_Check_MalformedNestedEndMarker (t * testing.T ) {
195+ // A malformed nested end marker (missing ?>) inside balanced
196+ // nesting should emit a diagnostic without decrementing depth.
197+ src := "<?mock\n key: a\n ?>\n <?mock\n key: b\n ?>\n inner\n <?/mock\n <?/mock?>\n <?/mock?>\n "
198+ f := newTestFile (t , "test.md" , src )
199+ d := & mockDirective {content : "" }
200+ e := NewEngine (d )
201+ diags := e .Check (f )
202+ found := false
203+ for _ , d := range diags {
204+ if strings .Contains (d .Message , "<?/mock is missing closing ?>" ) {
205+ found = true
206+ }
207+ }
208+ assert .True (t , found ,
209+ "expected malformed nested end marker diagnostic, got %v" , diags )
210+ }
211+
176212func TestEngine_Check_InvalidYAML (t * testing.T ) {
177213 src := "<?mock\n : invalid : yaml ::: [\n ?>\n <?/mock?>\n "
178214 f := newTestFile (t , "test.md" , src )
0 commit comments