ef55212a7e
- verify_article.sh: +4 CSS-Compliance-Checks (vorbestell-box, bsn-facts, veraltete Boxen, Inline-Styles) - fix_article_format.py: Auto-Fixer für Inline-Style-Stripping - journalistic-article-writing SKILL.md: QC-Pipeline + Template mit vorbestell-box - artikel_kingdom_rush_deal_20260710.html: PATCH 200 auf Joomla + Bild
68 lines
1.5 KiB
Python
68 lines
1.5 KiB
Python
#!/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 <artikel.html>
|
||
"""
|
||
import re, sys
|
||
|
||
if len(sys.argv) < 2:
|
||
print(f"Usage: {sys.argv[0]} <artikel.html>")
|
||
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'(<div[^>]*class="[^"]*vorbestell-box[^"]*")[^>]*>',
|
||
r'\1>',
|
||
html
|
||
)
|
||
fixes += n
|
||
|
||
# 2. Strip style="" from bsn-facts elements
|
||
html, n = re.subn(
|
||
r'(<div[^>]*class="[^"]*bsn-facts[^"]*")[^>]*>',
|
||
r'\1>',
|
||
html
|
||
)
|
||
fixes += n
|
||
|
||
# 3. Remove <div class="affiliate-box">...</div> blocks entirely
|
||
html, n = re.subn(
|
||
r'<div class="affiliate-box"[^>]*>.*?</div>\s*',
|
||
'',
|
||
html,
|
||
flags=re.DOTALL
|
||
)
|
||
fixes += n
|
||
|
||
# 4. Strip style="background:..." / style="border:..." from <div>s
|
||
# (but ONLY if they also have a class= — pure style-only divs stay)
|
||
html, n = re.subn(
|
||
r'(<div[^>]*class="[^"]*"[^>]*)\s+style="[^"]*(?:background|border)[^"]*"',
|
||
r'\1',
|
||
html
|
||
)
|
||
fixes += n
|
||
|
||
# 5. Strip style="" from <p> inside old-format deal boxes
|
||
html, n = re.subn(
|
||
r'<p style="[^"]*(?:margin|font-weight|font-size|color:#888)[^"]*"[^>]*>',
|
||
r'<p>',
|
||
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}")
|