-
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
23fd145
commit be6c750
Showing
2 changed files
with
48 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.") |