| 20 | |
| 21 | |
| 22 | def render(paths, output): |
| 23 | chunks = [] |
| 24 | for path in paths: |
| 25 | _front_matter, body, _start = read_post(path) |
| 26 | rendered = body_to_html(body) |
| 27 | # A comment with the source path keeps the combined file debuggable; |
| 28 | # the extractor ignores comments. |
| 29 | chunks.append(f"<!-- {html.escape(path)} -->\n<article>\n{rendered}\n</article>") |
| 30 | os.makedirs(os.path.dirname(output) or ".", exist_ok=True) |
| 31 | with open(output, "w", encoding="utf-8") as fh: |
| 32 | fh.write("<!DOCTYPE html>\n<html><body>\n") |
| 33 | fh.write("\n\n".join(chunks)) |
| 34 | fh.write("\n</body></html>\n") |
| 35 | |
| 36 | |
| 37 | def expand_paths(paths): |