import glob
import re

files = glob.glob('*.html')
for f in files:
    with open(f, 'r', encoding='utf-8') as file:
        content = file.read()
    
    # Remove the broken </li><li> and closing </li>
    content = content.replace('</li>\n                                <li><a href="gallery.html"', '            <a href="gallery.html"')
    content = content.replace('</a></li>\n            <a href="ministries.html"', '</a>\n            <a href="ministries.html"')
    
    # Also just in case the format is slightly different
    content = re.sub(r'</li>\s*<li><a href="gallery.html', r'\n            <a href="gallery.html', content)
    content = re.sub(r'About Us</a></li>', r'About Us</a>', content)
    
    with open(f, 'w', encoding='utf-8') as file:
        file.write(content)
