import sys with open('tmp_home.html', 'r', encoding='utf-8') as f: content = f.read() # Fix duplicated text content = content.replace( 'Kevin McKeand CoachingKevin McKeand Coaching', 'Kevin McKeand Coaching' ) # Fix logo size content = content.replace( "font-size: clamp(24px, 2.2vw, 36px);", "font-size: clamp(16px, 1.8vw, 20px);" ) # Fix top spacing more aggressively old_css_part = "body.home .wp-site-blocks { padding-top: 0 !important; }" new_css_part = """body.home .wp-site-blocks { padding-top: 0 !important; margin-top: 0 !important; } body.home main { margin-top: 0 !important; padding-top: 0 !important; } body.home { margin-top: 0 !important; padding-top: 0 !important; }""" if old_css_part in content: content = content.replace(old_css_part, new_css_part) else: content = content.replace("body { background: #1C3434; }", new_css_part + "\nbody { background: #1C3434; }") with open('tmp_home_fixed.html', 'w', encoding='utf-8') as f: f.write(content)