summaryrefslogtreecommitdiff
path: root/repo/www/generate-page.py
blob: a8dd81dc0c4fd08ded0217bbd841cadc65ab35be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python3

from argparse import ArgumentParser
from subprocess import run


def parse_arguments():
    parser = ArgumentParser()
    parser.add_argument(
        '--site-title', help='Prefix to add to <title>.'
    )
    parser.add_argument(
        '--title', help='Page title.'
    )
    parser.add_argument(
        'page', help='Page to convert to HTML.'
    )
    parser.add_argument(
        'output', help='Path to the output file.'
    )
    return parser.parse_args()


def main(arguments):
    pandoc = (
        'pandoc', '-s', arguments.page, '-o', arguments.output,
        '--lua-filter', 'convert-internal-links.lua',
        '--template', 'template.html', '-T', arguments.site_title,
        '-M', f'title={arguments.title}'
    )
    run(pandoc, check=True)


if __name__ == '__main__':
    main(parse_arguments())