#!/usr/bin/env python3
"""
Reference validator for GlitchCraft
Checks that all file references in HTML and manifest actually exist
"""
import json
import os
import re
import sys
from pathlib import Path
def check_file_exists(file_path, base_dir):
"""Check if a file exists relative to base directory."""
full_path = base_dir / file_path
return full_path.exists()
def extract_html_references(html_content):
"""Extract file references from HTML content."""
references = []
# Link href attributes
for match in re.finditer(r']+href=["\']([^"\']+)["\']', html_content):
href = match.group(1)
if not href.startswith(('http://', 'https://', '//', 'data:', '#')):
references.append(href)
# Script src attributes
for match in re.finditer(r'