mirror of https://github.com/eyhc1/rendercv.git
renderer: fix setup_jinja2_environment
This commit is contained in:
parent
06d426bd3b
commit
031687f5ab
|
@ -756,11 +756,11 @@ def setup_jinja2_environment() -> jinja2.Environment:
|
||||||
jinja2.Environment: The theme environment.
|
jinja2.Environment: The theme environment.
|
||||||
"""
|
"""
|
||||||
global jinja2_environment
|
global jinja2_environment
|
||||||
|
themes_directory = pathlib.Path(__file__).parent / "themes"
|
||||||
|
|
||||||
if jinja2_environment is None:
|
if jinja2_environment is None:
|
||||||
# create a Jinja2 environment:
|
# create a Jinja2 environment:
|
||||||
# we need to add the current working directory because custom themes might be used.
|
# we need to add the current working directory because custom themes might be used.
|
||||||
themes_directory = pathlib.Path(__file__).parent / "themes"
|
|
||||||
environment = jinja2.Environment(
|
environment = jinja2.Environment(
|
||||||
loader=jinja2.FileSystemLoader([pathlib.Path.cwd(), themes_directory]),
|
loader=jinja2.FileSystemLoader([pathlib.Path.cwd(), themes_directory]),
|
||||||
trim_blocks=True,
|
trim_blocks=True,
|
||||||
|
@ -795,6 +795,11 @@ def setup_jinja2_environment() -> jinja2.Environment:
|
||||||
environment.filters["escape_latex_characters"] = escape_latex_characters
|
environment.filters["escape_latex_characters"] = escape_latex_characters
|
||||||
|
|
||||||
jinja2_environment = environment
|
jinja2_environment = environment
|
||||||
|
else:
|
||||||
|
# update the loader in case the current working directory has changed:
|
||||||
|
jinja2_environment.loader = jinja2.FileSystemLoader(
|
||||||
|
[pathlib.Path.cwd(), themes_directory]
|
||||||
|
)
|
||||||
|
|
||||||
return jinja2_environment
|
return jinja2_environment
|
||||||
|
|
||||||
|
@ -1081,9 +1086,7 @@ def markdown_to_html(markdown_file_path: pathlib.Path) -> pathlib.Path:
|
||||||
html = html_template.render(html_body=html_body, title=title)
|
html = html_template.render(html_body=html_body, title=title)
|
||||||
|
|
||||||
# Write html into a file:
|
# Write html into a file:
|
||||||
html_file_path = (
|
html_file_path = markdown_file_path.parent / f"{markdown_file_path.stem}.html"
|
||||||
markdown_file_path.parent / f"{markdown_file_path.stem}.html"
|
|
||||||
)
|
|
||||||
html_file_path.write_text(html, encoding="utf-8")
|
html_file_path.write_text(html, encoding="utf-8")
|
||||||
|
|
||||||
return html_file_path
|
return html_file_path
|
||||||
|
|
Loading…
Reference in New Issue