#!/usr/bin/env python3 """Fix article HTML format for Article-Server compatibility. Ensures:
date, , Run: python3 fix_article_format.py /home/hermes/workspace/artikel.html """ import sys, re, os from datetime import datetime def fix_article(filepath): with open(filepath, 'r') as f: content = f.read() changed = False # 1. Fix
if re.search(r'
\1
', content) changed = True print(f" ✓") # 2. Add
if missing (using dateline or default) if '
' not in content: date_str = datetime.now().strftime("%d. %B %Y") # Try to extract date from dateline dl = re.search(r'
([^<]+)
', content) if dl: date_str = dl.group(1).split('·')[0].strip() # Insert after or after{date_str} · Lesezeit: ca. 5 Minuten
\n' if 'hinzugefügt: {date_str}") # 3. Add if missing if '\n' content = re.sub(r'(