-
Notifications
You must be signed in to change notification settings - Fork 3
/
generate
executable file
·53 lines (44 loc) · 1.65 KB
/
generate
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
from __future__ import print_function
import argparse
import os.path
import subprocess
def main():
# Setup argument parser and parse the arguments.
parser = argparse.ArgumentParser(
description="Simple driver for pandoc. " +
"Or use pandoc directly for more options.")
parser.add_argument(
"--format", "-f",
choices=["beamer", "slides", "handout"],
default="slides",
help="output format, slides is an alias for beamer")
parser.add_argument(
"--incremental",
"-i",
default=False,
action="store_true",
help="incremental display of lists")
parser.add_argument("source", help="Source markdown file")
args = parser.parse_args()
output = os.path.splitext(args.source)[0] + ".pdf" #".tex"
# Construct call to pandoc.
if args.format in ["beamer", "slides"]:
pan_args = ["pandoc", "-f", "markdown", "-V", "theme:PaloAlto"]
if args.incremental:
pan_args.append("--incremental")
pan_args.extend(["--write", "beamer",
"--template", "lecture.beamer",
"--out", output, args.source])
elif args.format == "handout":
pan_args = ["pandoc",
"--from", "markdown",
"--to", "latex",
"--template", "lecture.latex",
"--out", output,
args.source]
# Call pandoc to generate the pdf.
print("Executing:", " ".join(pan_args))
subprocess.check_call(pan_args)
if __name__ == "__main__":
main()