Files
BSN-Chatsystem/fix_article_format.py
T
Hermes Agent ef55212a7e fix: Kingdom Rush #15540 online mit Bild + Workflow gehärtet
- 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
2026-07-10 23:41:04 +02:00

68 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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}")