25 lines
949 B
Python
25 lines
949 B
Python
|
import os
|
||
|
|
||
|
# Chemin vers le dossier contenant les fichiers HTML
|
||
|
html_dir = "source/converted"
|
||
|
|
||
|
style_file="style_general.css"
|
||
|
css_content=""
|
||
|
with open(os.path.join(style_file), "r") as f:
|
||
|
css_content = f.read()
|
||
|
|
||
|
# Parcourir tous les fichiers HTML dans le dossier
|
||
|
for root, _, files in os.walk(html_dir):
|
||
|
for file in files:
|
||
|
if file.endswith(".html"):
|
||
|
# Ouvrir le fichier HTML en mode lecture
|
||
|
with open(os.path.join(root, file), "r") as f:
|
||
|
html_content = f.read()
|
||
|
|
||
|
# Ajouter la déclaration de charset UTF-8 et le doctype HTML
|
||
|
html_content = f"<!DOCTYPE html>\n<html lang=\"fr\">\n<head>\n<meta charset=\"UTF-8\">\n<style type='text/css'>{css_content}</style></head>\n<body>\n{html_content}\n</body>\n</html>"
|
||
|
|
||
|
# Écrire le contenu modifié dans le fichier HTML
|
||
|
with open(os.path.join(root, file), "w") as f:
|
||
|
f.write(html_content)
|