mirror of https://github.com/eyhc1/rendercv.git
add render function to tinytex
This commit is contained in:
parent
74cf3fc602
commit
70da19dc9b
|
@ -1,30 +1,44 @@
|
||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
|
|
||||||
from data.content import CurriculumVitae
|
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 os
|
||||||
import json
|
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")
|
if __name__ == "__main__":
|
||||||
with open(input_file_path) as file:
|
workspace = os.path.dirname(os.path.dirname(__file__))
|
||||||
raw_json = json.load(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:
|
cv = CurriculumVitae(**raw_json)
|
||||||
output_file_path = os.path.join(workspace, "tests", "outputs", "test.tex")
|
|
||||||
with open(output_file_path, "w") as file:
|
|
||||||
file.write(output_latex_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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
C:\GIT\rendercv\rendercv\tinytex\vendor\TinyTeX\bin\windows\latexmk.exe -lualatex -c test.tex
|
|
|
@ -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.")
|
Binary file not shown.
|
@ -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}
|
|
|
@ -1,13 +1,16 @@
|
||||||
# TinyTeX
|
# 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/fonts/opentype/FontAwesome and copy FontAwesome's opentype contents inside.
|
||||||
- mkdir TinyTeX/textmf-local/tex/latex/FontAwesome and copy FontAwesome's tex 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
|
- In TinyTeX/, remove all the files except LICENSE.CTAN and LICENSE.TL
|
||||||
- Remove TinyTeX/tlpg/
|
- Remove TinyTeX/tlpg/
|
||||||
|
|
Loading…
Reference in New Issue