Created
January 16, 2022 12:47
-
-
Save tarptaeya/0f6bf8b04e708fa0d4e46412995b5d65 to your computer and use it in GitHub Desktop.
init-book
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys | |
import subprocess | |
if __name__ == "__main__": | |
if len(sys.argv) < 2: | |
print("[usage] init-book NAME") | |
sys.exit(0) | |
name = sys.argv[1] | |
subprocess.call(["mkdir", "-p", name]) | |
os.chdir(name) | |
with open(os.path.join(os.path.dirname(__file__), "Makefile"), "r") as f: | |
makefile_text = f.read() | |
makefile_text = makefile_text.replace("%%NAME%%", name) | |
with open("Makefile", "w") as m: | |
m.write(makefile_text) | |
with open("metadata.yml", "w") as m: | |
m.write("") | |
subprocess.call(["mkdir", "-p", "src"]) | |
subprocess.call(["touch", "src/0000.md"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: | |
pandoc metadata.yml `ls src/*.md | sort` -o %%NAME%%.pdf \ | |
--table-of-contents \ | |
--number-sections \ | |
--pdf-engine=xelatex \ | |
-V mainfont="Palatino" \ | |
-V documentclass=report \ | |
-V papersize=A4 \ | |
-V geometry:margin=1in |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment