Execute:
python md2html.py mdfile.txt outoputfile.html
# md2html.py
import markdown
import sys
def md_to_html(input_file, output_file):
# Read the content of the Markdown file
with open(input_file, 'r', encoding='utf-8') as file:
md_content = file.read()
# Convert Markdown content to HTML
html_content = markdown.markdown(md_content)
# Write the HTML content to the output file
with open(output_file, 'w', encoding='utf-8') as file:
file.write(html_content)
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: python script.py ")
else:
input_file = sys.argv[1]
output_file = sys.argv[2]
md_to_html(input_file, output_file)
print(f"HTML file created: {output_file}")