mirror of https://github.com/eyhc1/rendercv.git
try to add linux support
This commit is contained in:
parent
9a6fca2a94
commit
b83054336e
|
@ -358,14 +358,13 @@ def run_latex(latex_file_path):
|
|||
output_file = latex_file.replace(".tex", ".pdf")
|
||||
output_file_path = os.path.join(os.path.dirname(latex_file_path), output_file)
|
||||
|
||||
if os.name == "nt":
|
||||
# remove all files except the .tex file
|
||||
for file in os.listdir(os.path.dirname(latex_file_path)):
|
||||
if file.endswith(".tex") or file == "fonts":
|
||||
continue
|
||||
# remove the file:
|
||||
os.remove(os.path.join(os.path.dirname(latex_file_path), file))
|
||||
|
||||
if os.name == "nt":
|
||||
tinytex_path = os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
"vendor",
|
||||
|
@ -373,9 +372,21 @@ def run_latex(latex_file_path):
|
|||
"bin",
|
||||
"windows",
|
||||
)
|
||||
executable = os.path.join(tinytex_path, "latexmk.exe")
|
||||
|
||||
else:
|
||||
tinytex_path = os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
"vendor",
|
||||
"TinyTeX",
|
||||
"bin",
|
||||
"x86_64-linux",
|
||||
)
|
||||
executable = os.path.join(tinytex_path, "latexmk")
|
||||
|
||||
subprocess.run(
|
||||
[
|
||||
f"{tinytex_path}\\latexmk.exe",
|
||||
executable,
|
||||
"-lualatex",
|
||||
f"{latex_file}",
|
||||
"-synctex=1",
|
||||
|
@ -385,11 +396,6 @@ def run_latex(latex_file_path):
|
|||
cwd=os.path.dirname(latex_file_path),
|
||||
stdout=subprocess.DEVNULL,
|
||||
)
|
||||
else:
|
||||
raise NotImplementedError(
|
||||
"The current OS is not supported! Only Windows is supported at the moment."
|
||||
)
|
||||
|
||||
end_time = time.time()
|
||||
time_taken = end_time - start_time
|
||||
logger.info(
|
||||
|
|
|
@ -399,6 +399,12 @@ class TestDataModel(unittest.TestCase):
|
|||
# Remove the output directory:
|
||||
shutil.rmtree(output_folder_path)
|
||||
|
||||
def test_run_latex(self):
|
||||
latex_file_path = os.path.join(
|
||||
os.path.dirname(__file__), "reference_files", "John_Doe_CV.tex"
|
||||
)
|
||||
|
||||
rendering.run_latex(latex_file_path)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in New Issue