forked from unit/ciclostile
32 lines
780 B
Python
Executable File
32 lines
780 B
Python
Executable File
#!/usr/bin/env python3
|
|
import os
|
|
import ciclostile
|
|
|
|
|
|
working_dir = os.getcwd()
|
|
|
|
target_path, template_path, markdown_path = [
|
|
os.path.join(working_dir, folder_name)
|
|
for folder_name in ['target', 'templates', 'markdown']
|
|
]
|
|
|
|
|
|
def valid_md(md_file):
|
|
full_name = os.path.join(markdown_path, md_file)
|
|
return os.path.isfile(full_name) and full_name.endswith('.md')
|
|
|
|
|
|
def main():
|
|
for md_file in os.listdir(markdown_path):
|
|
if valid_md(md_file):
|
|
page_name = os.path.splitext(md_file)[0]
|
|
page = ciclostile.render(page_name, markdown_path, template_path)
|
|
|
|
out_path = os.path.join(target_path, page_name + '.html')
|
|
with open(out_path, 'w') as f:
|
|
f.write(page)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|