Skip to content
Permalink
70f25eeaba
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
58 lines (45 sloc) 1.82 KB
"""
Python script to build a dissertaion based on Markdown / Pandoc
TODO: Options?
"""
import subprocess
import os
# --------------- CHANGE THESE TWO LINES -------------------------
OUTPUT_FILE = "Disso.pdf"
#If you Reame the Header file you will need to let the script know.
STU_HEADER_FILE = "Dissertation.md" #Students Header File
#ENTER ALL THE SOURCE FILES THAT YOU HAVE IN THE DISSERTAION HERE.
SOURCE_FILES = ["Introduction.md"]
#Are you using the Recommended Submodule Approach
SUBMODULE = True
#If you rename the Templates repository, Let the script know.
SUBMODULE_PATH="Template"
# --------------- END OF STUFF THAT YOU NEED TO CHANGE -------------------------
def buildCommand():
"""Build the list that we send to pandoc"""
HEADER_FILE = "Header.md"
SUB_HEADER_FILE = "SubHeader.md"
#Needed otherwise refs come on the same page
FOOTER_FILE = "References.md"
# Pandoc Template
LATEX_TEMPLATE = "Template/disso.latex"
if SUBMODULE:
HEADER_FILE = os.path.join(SUBMODULE_PATH, SUB_HEADER_FILE)
FOOTER_FILE = os.path.join(SUBMODULE_PATH, FOOTER_FILE)
LATEX_TEMPLATE = os.path.join(SUBMODULE_PATH, LATEX_TEMPLATE)
PANDOC_OPTS = ["--filter=pandoc-citeproc",
"--template={0}".format(LATEX_TEMPLATE),
"--top-level-division=chapter"]
#Actually Build the list
commandList = ["pandoc"]
commandList.extend(PANDOC_OPTS) #Add the options
commandList.append(STU_HEADER_FILE) #Students Headderfile
commandList.append(HEADER_FILE) #Header File
commandList.extend(SOURCE_FILES) #STUDENT source
commandList.append(FOOTER_FILE) #FOOTER FILE
commandList.append("-o")
commandList.append(OUTPUT_FILE)
subprocess.run(commandList)
if __name__ == "__main__":
#Build the damm thing
buildCommand()