diff --git a/rendercv/rendercv.py b/rendercv/rendercv.py index 2198cb8..64931cd 100644 --- a/rendercv/rendercv.py +++ b/rendercv/rendercv.py @@ -1,30 +1,44 @@ from jinja2 import Environment, FileSystemLoader + from data.content import CurriculumVitae +# from . import tinytex # https://github.com/praw-dev/praw/blob/master/praw/reddit.py +# from . import templates, sonra mesela: classic.render() tarzi seyler olabilir +from tinytex.render import render + import os import json -workspace = os.path.dirname(os.path.dirname(__file__)) -environment = Environment(loader=FileSystemLoader(os.path.join(workspace, "rendercv", "templates"))) -environment.block_start_string = "((*" -environment.block_end_string = "*))" -environment.variable_start_string = "(((" -environment.variable_end_string = ")))" -environment.comment_start_string = "((=" -environment.comment_end_string = "=))" -template = environment.get_template("template1.tex.j2") -input_file_path = os.path.join(workspace, "tests", "inputs", "test.json") -with open(input_file_path) as file: - raw_json = json.load(file) +if __name__ == "__main__": + workspace = os.path.dirname(os.path.dirname(__file__)) + templateName = "classic" + templatePath = os.path.join(workspace, "rendercv", "templates", templateName) + environment = Environment(loader=FileSystemLoader(templatePath)) + environment.block_start_string = "((*" + environment.block_end_string = "*))" + environment.variable_start_string = "(((" + environment.variable_end_string = ")))" + environment.comment_start_string = "((=" + environment.comment_end_string = "=))" -data = CurriculumVitae(**raw_json) + template = environment.get_template(f"{templateName}.tex.j2") -output_latex_file = template.render(data=data) + input_file_path = os.path.join(workspace, "tests", "inputs", "test.json") + with open(input_file_path) as file: + raw_json = json.load(file) -# Create an output file and write the rendered LaTeX code to it: -output_file_path = os.path.join(workspace, "tests", "outputs", "test.tex") -with open(output_file_path, "w") as file: - file.write(output_latex_file) + cv = CurriculumVitae(**raw_json) - \ No newline at end of file + output_latex_file = template.render(cv=cv) + + # Create an output file and write the rendered LaTeX code to it: + output_file_path = os.path.join(workspace, "tests", "outputs", "test.tex") + with open(output_file_path, "w") as file: + file.write(output_latex_file) + + render(output_file_path) + + + + \ No newline at end of file diff --git a/rendercv/tinytex/command.txt b/rendercv/tinytex/command.txt deleted file mode 100644 index 507b65d..0000000 --- a/rendercv/tinytex/command.txt +++ /dev/null @@ -1 +0,0 @@ -C:\GIT\rendercv\rendercv\tinytex\vendor\TinyTeX\bin\windows\latexmk.exe -lualatex -c test.tex \ No newline at end of file diff --git a/rendercv/tinytex/render.py b/rendercv/tinytex/render.py new file mode 100644 index 0000000..7f47808 --- /dev/null +++ b/rendercv/tinytex/render.py @@ -0,0 +1,29 @@ +import os +import subprocess + + +def render(latexFilePath): + latexFilePath = os.path.normpath(latexFilePath) + if os.name == "nt": + tinytexPath = os.path.join( + os.path.dirname(__file__), + "vendor", + "TinyTeX", + "bin", + "windows", + ) + subprocess.run( + [ + f"{tinytexPath}\\latexmk.exe", + "-lualatex", + "-c", + "test.tex", + "-synctex=1", + "-interaction=nonstopmode", + "-file-line-error", + "test.tex", + ], + cwd=os.path.dirname(latexFilePath), + ) + else: + print("Only Windows is supported for now.") diff --git a/rendercv/tinytex/test.pdf b/rendercv/tinytex/test.pdf deleted file mode 100644 index 11c51d2..0000000 Binary files a/rendercv/tinytex/test.pdf and /dev/null differ diff --git a/rendercv/tinytex/test.tex b/rendercv/tinytex/test.tex deleted file mode 100644 index 8161429..0000000 --- a/rendercv/tinytex/test.tex +++ /dev/null @@ -1,39 +0,0 @@ -\documentclass[10pt, a4paper]{memoir} - -% =========== -% =========== -% USER INPUTS: -\newcommand{\AUTHOR}{Sina Atalay} - -\newcommand{\PRIMARYCOLOR}{0,79,144} % In RGB out of 255 - -\newcommand{\PageXMargin}{0.53in} -\newcommand{\PageYMargin}{0.53in} - -\newcommand{\TopMarginOfSections}{0.13cm} -\newcommand{\BottomMarginOfSections}{0.13cm} - -\newcommand{\YMarginBetweenEntries}{0.12cm} -\newcommand{\YMarginBetweenBullets}{0.07cm} -\newcommand{\LeftMarginOfBullets}{0.7cm} - -\newcommand{\DateandLocationWidth}{3.7cm} -% =========== -% =========== - -\input{preamble} - -\begin{document} - % Test out the 4 main entry types with the commands below: - \Header{a}{b}{c}{d}{e}{f} - \section{EducationEntry} - \EducationEntry{a}{b}{c}{d}{e}{f}{g}{j} - \section{ExperienceEntry} - \ExperienceEntry{a}{b}{c}{d}{e}{f}{g}{j} - \section{NormalEntry} - \NormalEntry{a}{b}{c}{d}{e}{f} - \section{OneLineEntry} - \OneLineEntry{a}{b} - - -\end{document} \ No newline at end of file diff --git a/rendercv/tinytex/vendor/README.md b/rendercv/tinytex/vendor/README.md index 7c58fcb..e6d47fb 100644 --- a/rendercv/tinytex/vendor/README.md +++ b/rendercv/tinytex/vendor/README.md @@ -1,13 +1,16 @@ # TinyTeX -Modifications that have been made to TinyTeX: +Normally, this directory should contain a `TinyTeX` folder with all the TinyTeX binaries. I couldn't figure out how to get a minimal TinyTeX that can render a CV and have a small file size, so I don't push TinyTeX to Github for now. -## FontAwesome +## Modifications that have been made to TinyTeX +Attempts to make TinyTeX smaller for CV purposes only. + +### FontAwesome - mkdir TinyTeX/textmf-local/fonts/opentype/FontAwesome and copy FontAwesome's opentype contents inside. - mkdir TinyTeX/textmf-local/tex/latex/FontAwesome and copy FontAwesome's tex contents inside. -## Removing files +### Removing files - In TinyTeX/, remove all the files except LICENSE.CTAN and LICENSE.TL - Remove TinyTeX/tlpg/