mirror of
https://forge.chapril.org/tykayn/orgmode-to-gemini-blog
synced 2025-06-20 09:04:42 +02:00
up
This commit is contained in:
parent
0b9f66167c
commit
0a189bd6ad
151 changed files with 18303 additions and 565 deletions
|
@ -12,23 +12,33 @@ args = parser.parse_args()
|
|||
# Style CSS minimaliste
|
||||
style_file = args.style
|
||||
css_content = ""
|
||||
with open(os.path.join(style_file), "r") as f:
|
||||
css_content = f.read()
|
||||
css_content = "<style type='text/css'>{css_content}</style>"
|
||||
|
||||
# inline_the_css=False
|
||||
inline_the_css=True
|
||||
|
||||
if inline_the_css:
|
||||
with open(os.path.join(style_file), "r") as f:
|
||||
css_content = f.read()
|
||||
css_content = "<style type='text/css'>{css_content}</style>"
|
||||
|
||||
html_dir = args.html_dir
|
||||
|
||||
|
||||
def enrich_one_file(file):
|
||||
print('enrich html file:',os.path.join(root, file))
|
||||
# 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, le doctype HTML et le titre du site Web
|
||||
html_content = f"<!DOCTYPE html>\n<html lang=\"fr\">\n<head>\n<meta charset=\"UTF-8\">\n<title>{args.title}</title>\n{css_content}<link type='stylesheet/css' href='/style.css'></link></head>\n<body>\n<a href='/'>Retour à l'Accueil</a><hr/>{html_content}\n<footer><hr/><a href='/'>Retour à l'Accueil</a></footer></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)
|
||||
# Parcourir tous les fichiers HTML dans le dossier
|
||||
for root, _, files in os.walk(html_dir):
|
||||
print(files)
|
||||
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, le doctype HTML et le titre du site Web
|
||||
html_content = f"<!DOCTYPE html>\n<html lang=\"fr\">\n<style type='text/css' src='/style.css'></style><head>\n<meta charset=\"UTF-8\">\n<title>{args.title}</title>\n{css_content}</head>\n<body>\n<a href='/'>Retour à l'Accueil</a><hr/>{html_content}\n<footer><hr/><a href='/'>Retour à l'Accueil</a></footer></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)
|
||||
enrich_one_file(file)
|
Loading…
Add table
Add a link
Reference in a new issue