2 # -*- coding: utf-8 -*-
4 # computes an index file in markdown/index.md from ./index.md with all the other md files referenced
11 output_dir = "markdown"
13 index_line_format = " * [{title}]({base}.html)\n"
17 def get_title(filename):
18 with open(filename) as input:
20 if line.startswith(TITLE):
21 return line[len(TITLE):].strip()
25 if not os.path.isfile(source):
26 print("Source not found {}".format(source))
29 output = os.path.join(output_dir, source)
30 with open(output, 'w') as result:
32 with open(source) as input:
33 result.write(input.read())
34 for other in sys.argv[1:]:
35 dir = os.path.dirname(other) or "."
36 base = os.path.basename(other).replace(".md", "")
37 title = get_title(other)
38 # skip index from the index...
42 #result.write(index_line_format.format(**locals()))
43 print("(Over)wrote {}".format(output))