def make_header(pandoc_format, title, categories):
    """
    Generate pandoc header based on given metadata.
    """
    lines = [
        "---",
        "format: " + pandoc_format,
        "title: " + title,
        "...",
        ]
    if categories is not None and len(categories) > 0:
        lines.insert(2, "categories: " + " ".join(categories))
    # separate the header from the rest of the file via empty line, with
    # exception of orgmode files ...
    if pandoc_format == "org":
        ending ="\n"
    else:
        ending ="\n\n"
    return "\n".join(lines) + ending