renderer: allow users to use any local latex command

This commit is contained in:
Sina Atalay 2024-03-29 18:09:10 +01:00
parent d070a097a1
commit 4d26c7335c
1 changed files with 7 additions and 7 deletions

View File

@ -890,7 +890,7 @@ def generate_latex_file_and_copy_theme_files(
def latex_to_pdf( def latex_to_pdf(
latex_file_path: pathlib.Path, use_local_latex: bool = False latex_file_path: pathlib.Path, local_latex_command: Optional[str] = None
) -> pathlib.Path: ) -> pathlib.Path:
"""Run TinyTeX with the given $\\LaTeX$ file to generate the PDF. """Run TinyTeX with the given $\\LaTeX$ file to generate the PDF.
@ -903,10 +903,10 @@ def latex_to_pdf(
if not latex_file_path.is_file(): if not latex_file_path.is_file():
raise FileNotFoundError(f"The file {latex_file_path} doesn't exist!") raise FileNotFoundError(f"The file {latex_file_path} doesn't exist!")
if use_local_latex: if local_latex_command:
executable = "pdflatex" executable = local_latex_command
# check if pdflatex is installed: # check if the command is working:
try: try:
subprocess.run( subprocess.run(
[executable, "--version"], [executable, "--version"],
@ -915,9 +915,9 @@ def latex_to_pdf(
) )
except FileNotFoundError: except FileNotFoundError:
raise FileNotFoundError( raise FileNotFoundError(
"[blue]pdflatex[/blue] isn't installed! Please install LaTeX and try" f"[blue]{executable}[/blue] isn't installed! Please install LaTeX and"
" again (or don't use the" " try again (or don't use the"
" [bright_black]--use_local_latex[/bright_black] option)." " [bright_black]--use-local-latex-command[/bright_black] option)."
) )
else: else:
tinytex_binaries_directory = ( tinytex_binaries_directory = (