import re

with open('/var/www/blog/index.html') as f:
    content = f.read()

# Find the April 11 post card
m = re.search(r'(<article class="post-card">.*?a-stock-sector-report-2026-04-11.*?</article>)', content, re.DOTALL)
template = m.group(1) if m else ''
print('TEMPLATE_LEN:', len(template))

# Make today's card
today_card = template.replace('2026-04-11', '2026-04-21').replace('a-stock-sector-report-2026-04-11', 'a-stock-sector-report-2026-04-21')

# Insert after April 11
idx = content.find('a-stock-sector-report-2026-04-11')
if idx > 0 and today_card:
    # Find the end of April 11 card
    end_tag = content.find('</article>', idx)
    insert_pos = end_tag + len('</article>')
    new_content = content[:insert_pos] + today_card + content[insert_pos:]
    with open('/var/www/blog/index.html', 'w') as f:
        f.write(new_content)
    print('Done, new size:', len(new_content))
else:
    print('ERROR: could not find insertion point or template')
