re-implement scan_close_code_fence() in regel; more porting