import re

with open('/Applications/XAMPP/xamppfiles/htdocs/bus.online/index.html', 'r') as f:
    html = f.read()

# I will replace carrier-icon and add carrier-card-body
def repl_card(match):
    icon_style = match.group(1)
    content = match.group(2)
    # The icon_style has background-image: url(...)
    # We replace carrier-icon with carrier-card-img
    return f'<div class="carrier-card-img" {icon_style}></div>\n          <div class="carrier-card-body">\n{content}          </div>'

# Regex to match the inside of each carrier-card
# <div class="carrier-icon" (style="...")></div>
# (rest of the card up to </a>)
pattern = r'<div class="carrier-icon"\s*(style="[^"]+")></div>\s*(<h3>.*?</a>)'
html = re.sub(pattern, repl_card, html, flags=re.DOTALL)

with open('/Applications/XAMPP/xamppfiles/htdocs/bus.online/index.html', 'w') as f:
    f.write(html)
print("Updated index.html HTML structure for carriers.")
