diff options
author | Julian T <julian@jtle.dk> | 2021-03-24 16:45:09 +0100 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2021-03-24 16:45:09 +0100 |
commit | d596b67e48e7c85379e1283187687edc2fc19b8f (patch) | |
tree | 64f28a444f553d9f73b6d6c4498aff4f4fa73f2f /render.py | |
parent | 501f3e928cf652e691853acad6fed4de25338f63 (diff) |
Added assignments for dig
Diffstat (limited to 'render.py')
-rwxr-xr-x | render.py | 24 |
1 files changed, 15 insertions, 9 deletions
@@ -11,14 +11,18 @@ tex_template = """\\documentclass[12pt]{article} \\usepackage{amsmath} \\usepackage{amsfonts} \\usepackage{mdframed} +\\usepackage{float} + +\\usepackage{tikz} +\\usetikzlibrary{automata, positioning, arrows} \\newtheorem{definition}{Definition} \\newtheorem{lemma}{Lemma} \\newtheorem{theorem}{Theorem} -{% if p is not none %} -\\title{ {{title}} } -{% endif %} +{% for thing in before %} +{{thing}} +{% endfor %} \\setlength{\parindent}{0cm} \\setlength{\parskip}{0.3em} @@ -32,6 +36,8 @@ tex_template = """\\documentclass[12pt]{article} \\end{document} """ +beforewhitelist = ["title", "date"] + parser = argparse.ArgumentParser() parser.add_argument("file", help="The file to load") @@ -39,21 +45,21 @@ args = parser.parse_args() # Load the file content = [] -title = None +before = [] with open(args.file, "r") as f: for line in f: - m = re.findall("\\\\title\{(.*)\}", line) - if m: - title = m[0] + m = re.findall("\\\\([a-zA-Z]*)\{.*\}", line) + if m and m[0] in beforewhitelist: + before.append(line) else: content.append(line) content = "".join(content) -print(content) # Write to output tmpl = jinja2.Template(tex_template) -output = tmpl.render(title=title,content=content) +output = tmpl.render(before=before,content=content) +print(output) # Create build folder if not os.path.exists("render_build"): |