34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
import os
|
|
|
|
keywords = "keywords.md"
|
|
|
|
with open(keywords) as f:
|
|
content = f.readlines()
|
|
content = [y for x in content for y in x.strip().split(':') ]
|
|
|
|
keyword = content[0]
|
|
directory = "content/" + content[0]
|
|
filename = content[1].replace("content", "")
|
|
htmlfilename = filename.replace(".md", ".html")
|
|
article = content[2]
|
|
|
|
if os.path.exists(directory + "/index.md"):
|
|
os.remove(directory + "/index.md")
|
|
if os.path.exists(directory + "/index.html"):
|
|
os.remove(directory + "/index.html")
|
|
if os.path.exists(directory):
|
|
os.rmdir(directory)
|
|
|
|
if not os.path.exists(directory):
|
|
os.makedirs(directory)
|
|
|
|
fileindex=directory + "/index.md"
|
|
with open(fileindex, 'a') as f:
|
|
if f.tell() == 0:
|
|
f.write('---\ntitle: ' + keyword.capitalize() + "\n---\n")
|
|
f.write("- [" + article + "](" + htmlfilename + ")\n")
|
|
|
|
fileindexhtml=directory + "/index.html"
|
|
os.system('pandoc --template=lib/template.html -c lib/pandoc.css ' + fileindex + ' -o ' + fileindexhtml)
|
|
|