ciclostile/build/scripts-3.6/ciclostile_render
2018-04-07 04:17:49 +02:00

32 lines
809 B
Python
Executable File

#!/home/subnixr/.virtualenvs/ciclostile/bin/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()