import re
import glob

html_files = glob.glob('/Applications/XAMPP/xamppfiles/htdocs/bus.online/*.html')

for filepath in html_files:
    with open(filepath, 'r') as f:
        content = f.read()
    
    # Fix center/cover syntax
    # style="background: url('https://loremflickr.com/400/250/newyork,city?random=1') center/cover;"
    # into style="background-image: url('...'); background-size: cover; background-position: center;"
    
    # regex to find style="background: url('...') center/cover; ... "
    # and replace with style="background-image: url('...'); background-size: cover; background-position: center; ... "
    content = re.sub(r'background:\s*url\(([^)]+)\)\s*center/cover', r'background-image: url(\1); background-size: cover; background-position: center', content)
    
    # Also if there is color: transparent; it's fine.
    
    with open(filepath, 'w') as f:
        f.write(content)

print("Fixed CSS background shorthand syntax.")
