import os import re import sys sys.stdout.reconfigure(encoding='utf-8') with open('tools/test_extract.py', 'r', encoding='utf-8') as fp: code = fp.read() exec(code[:code.find("test_files = [")]) def build_html(filepath, html): title, meta_desc, content, pattern = extract_content(html) # パンくずの確認と補完 has_breadcrumbs = 'wiki-breadcrumbs' in content or 'wiki-breadcrumb' in content if not has_breadcrumbs: genre = "ダンジョン攻略" if "dungeons" in filepath else ("レイド攻略" if "raids" in filepath else "討滅戦攻略") clean_title = re.sub(r'【.*?】', '', title).replace('完全攻略', '').replace('攻略', '').strip() breadcrumb = f'
\n トップ > {genre} > {clean_title}\n
\n\n' content = breadcrumb + content else: # id="wiki-breadcrumb" を class="wiki-breadcrumbs" に統一 content = re.sub(r'', '
', content) # 空のパンくずの場合は置換 if '
' in content or '
\s*
' in content: genre = "ダンジョン攻略" if "dungeons" in filepath else ("レイド攻略" if "raids" in filepath else "討滅戦攻略") clean_title = re.sub(r'【.*?】', '', title).replace('完全攻略', '').replace('攻略', '').strip() new_bc = f'
\n トップ > {genre} > {clean_title}\n
' content = re.sub(r'
\s*
', new_bc, content) template = f''' {title} {meta_desc}
{content}

© SQUARE ENIX CO., LTD. All Rights Reserved. | FINAL FANTASY XIV

FF14 攻略Wiki (Seesaa Wiki ニュートラルグレー テンプレート完全準拠)

''' return template for p in ['trials/ultima_weapon.html', 'trials/extreme_hades.html']: with open(p, 'r', encoding='utf-8', errors='ignore') as fp: html = fp.read() res = build_html(p, html) lines = res.splitlines() print(f"=== {p} PREVIEW (最初の35行) ===") for l in lines[:35]: print(l) print(f"=== {p} PREVIEW (最後の20行) ===") for l in lines[-20:]: print(l) print("\n" + "="*50 + "\n")