import os, re

with open('index.html', 'r', encoding='utf-8') as f:
    content = f.read()
    match = re.search(r'<nav class="ul-header-nav">.*?</nav>', content, re.DOTALL)
    if match:
        new_nav = match.group(0)
    else:
        print('Nav not found in index.html')
        exit(1)

files = [f for f in os.listdir('.') if f.endswith('.html') and f != 'index.html']
for file in files:
    with open(file, 'r', encoding='utf-8') as f:
        file_content = f.read()
    if '<nav class="ul-header-nav">' in file_content:
        updated_content = re.sub(r'<nav class="ul-header-nav">.*?</nav>', new_nav, file_content, flags=re.DOTALL)
        with open(file, 'w', encoding='utf-8') as f:
            f.write(updated_content)
        print(f'Updated {file}')

