Skip to content

Commit

Permalink
create rendering module
Browse files Browse the repository at this point in the history
  • Loading branch information
sinaatalay committed Sep 10, 2023
1 parent 23fd145 commit be6c750
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 44 deletions.
48 changes: 48 additions & 0 deletions rendercv/rendering.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""This module implements rendering utilities.
"""
import os
import subprocess

def render_template(template, data):
pass

def run_latex(latexFilePath):
"""
Run LuaLateX on the given LaTeX file and generate a PDF.
:param latexFilePath: The path to the LaTeX file to compile.
:type latexFilePath: str
:return: None
:rtype: None
"""
latexFilePath = os.path.normpath(latexFilePath)
latexFile = os.path.basename(latexFilePath)

if os.name == "nt":
# remove all files except the .tex file
for file in os.listdir(os.path.dirname(latexFilePath)):
if file.endswith(".tex"):
continue
os.remove(os.path.join(os.path.dirname(latexFilePath), file))

tinytexPath = os.path.join(
os.path.dirname(__file__),
"vendor",
"TinyTeX",
"bin",
"windows",
)
subprocess.run(
[
f"{tinytexPath}\\latexmk.exe",
"-lualatex",
# "-c",
f"{latexFile}",
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
],
cwd=os.path.dirname(latexFilePath),
)
else:
print("Only Windows is supported for now.")
44 changes: 0 additions & 44 deletions rendercv/tinytex.py
Original file line number Diff line number Diff line change
@@ -1,47 +1,3 @@
"""
This module implements a handler for TinyTeX.
"""

import os
import subprocess

def run_latex(latexFilePath):
"""
Run LuaLateX on the given LaTeX file and generate a PDF.
:param latexFilePath: The path to the LaTeX file to compile.
:type latexFilePath: str
:return: None
:rtype: None
"""
latexFilePath = os.path.normpath(latexFilePath)
latexFile = os.path.basename(latexFilePath)

if os.name == "nt":
# remove all files except the .tex file
for file in os.listdir(os.path.dirname(latexFilePath)):
if file.endswith(".tex"):
continue
os.remove(os.path.join(os.path.dirname(latexFilePath), file))

tinytexPath = os.path.join(
os.path.dirname(__file__),
"vendor",
"TinyTeX",
"bin",
"windows",
)
subprocess.run(
[
f"{tinytexPath}\\latexmk.exe",
"-lualatex",
# "-c",
f"{latexFile}",
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
],
cwd=os.path.dirname(latexFilePath),
)
else:
print("Only Windows is supported for now.")

0 comments on commit be6c750

Please sign in to comment.