forked from InfoSansOrdi/pedago-rennes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmd-to-html.py
More file actions
executable file
·27 lines (19 loc) · 1.09 KB
/
Copy pathmd-to-html.py
File metadata and controls
executable file
·27 lines (19 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#! /bin/env python
import sys
import os
import markdown
def convert_markdown_to_html(input_md, output_html):
if not os.path.isfile(input_md):
print(f"Error: The file {input_md} does not exist.")
return
with open(input_md, "r", encoding="utf-8") as f:
html_content = markdown.markdown(f.read())
html_content = f"<!DOCTYPE html><html lang=\"fr\"><head><meta charset=\"utf-8\"></head><body> {html_content} </body></html>"
with open(output_html, "w", encoding="utf-8") as f:
f.write(html_content)
print(f"HTML file generated: {output_html}")
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: python script.py input.md output.html")
else:
convert_markdown_to_html(sys.argv[1], sys.argv[2])