$rawLine) { $lineNo = $i + 1; $line = trim($rawLine); if ($line === '' || str_starts_with($line, '//')) { continue; } if (!str_starts_with($line, '-')) { $finishQuestion(); $question = $line; $questionLine = $lineNo; continue; } if ($question === null) { $errors[] = "Line {$lineNo}: answer appears before any question."; continue; } if (str_starts_with($line, '-|')) { $answer = trim(substr($line, 2)); } else { $answer = trim(substr($line, 1)); } if ($answer === '') { $errors[] = "Line {$lineNo}: answer is empty."; } $answers++; } $finishQuestion(); $content = file_get_contents($path) ?: ''; preg_match_all('/]*src=["\']([^"\']+)["\'][^>]*>/i', $content, $matches); foreach ($matches[1] ?? [] as $src) { if (str_starts_with($src, 'img/') && !is_file($baseDir . '/' . $src)) { $errors[] = "Missing image referenced from pytania.txt: {$src}"; } } if ($questionCount === 0) { $errors[] = 'No questions found.'; } if ($errors !== []) { foreach ($errors as $error) { fwrite(STDERR, $error . PHP_EOL); } exit(1); } echo "OK: {$questionCount} questions validated.\n";