18 lines
592 B
Python
Executable File
18 lines
592 B
Python
Executable File
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
import sys
|
|
import markdown
|
|
from template import template
|
|
from pymdownx.superfences import SuperFencesCodeExtension
|
|
|
|
def main():
|
|
md = markdown.Markdown(extensions = ["meta", "extra", "toc", SuperFencesCodeExtension(preserve_tabs=True)])
|
|
with open(sys.argv[1], "r", encoding="utf-8") as file_in:
|
|
html = md.convert(file_in.read())
|
|
output = template(html, sys.argv[2], ".html", md.Meta) if "template" in md.Meta else html
|
|
with open(sys.argv[2], "w+", encoding="utf-8") as file_out:
|
|
file_out.write(output)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|