#!/usr/bin/env python3 """ fix_article_format.py — Stripped Inline-Styles von BSN-Standard-Klassen. Entfernt veraltete Box-Formate aus Artikel-HTML. Usage: python3 fix_article_format.py """ import re, sys if len(sys.argv) < 2: print(f"Usage: {sys.argv[0]} ") sys.exit(1) filepath = sys.argv[1] with open(filepath) as f: html = f.read() original = html fixes = 0 # 1. Strip style="" from vorbestell-box elements html, n = re.subn( r'(]*class="[^"]*vorbestell-box[^"]*")[^>]*>', r'\1>', html ) fixes += n # 2. Strip style="" from bsn-facts elements html, n = re.subn( r'(]*class="[^"]*bsn-facts[^"]*")[^>]*>', r'\1>', html ) fixes += n # 3. Remove
...
blocks entirely html, n = re.subn( r'
]*>.*?
\s*', '', html, flags=re.DOTALL ) fixes += n # 4. Strip style="background:..." / style="border:..." from
s # (but ONLY if they also have a class= — pure style-only divs stay) html, n = re.subn( r'(]*class="[^"]*"[^>]*)\s+style="[^"]*(?:background|border)[^"]*"', r'\1', html ) fixes += n # 5. Strip style="" from

inside old-format deal boxes html, n = re.subn( r'

]*>', r'

', html ) fixes += n if html != original: with open(filepath, 'w') as f: f.write(html) print(f"✅ {fixes} Fixes angewandt auf {filepath}") else: print(f"ℹ️ Keine Fixes nötig für {filepath}")