mirror of https://github.com/eyhc1/rendercv.git
compute last updated date on python side
This commit is contained in:
parent
d1b05979de
commit
9607f15751
|
@ -1,4 +1,4 @@
|
|||
"""RenderCV package.
|
||||
r"""RenderCV package.
|
||||
|
||||
It parses the user input YAML/JSON file and validates the data (checks spelling mistakes, checks if the dates are consistent, etc.). Then, with the data, it creates a $\LaTeX$ file and renders it with [TinyTeX](https://yihui.org/tinytex/).
|
||||
"""
|
||||
|
|
|
@ -126,6 +126,7 @@ def make_it_bold(value: str, match_str: str) -> str:
|
|||
else:
|
||||
return value
|
||||
|
||||
|
||||
def make_it_underlined(value: str, match_str: str) -> str:
|
||||
"""Make the matched parts of the string underlined.
|
||||
|
||||
|
@ -156,6 +157,7 @@ def make_it_underlined(value: str, match_str: str) -> str:
|
|||
else:
|
||||
return value
|
||||
|
||||
|
||||
def make_it_italic(value: str, match_str: str) -> str:
|
||||
"""Make the matched parts of the string italic.
|
||||
|
||||
|
@ -186,6 +188,19 @@ def make_it_italic(value: str, match_str: str) -> str:
|
|||
else:
|
||||
return value
|
||||
|
||||
|
||||
def print_today() -> str:
|
||||
"""Return today's date.
|
||||
|
||||
Returns:
|
||||
str: Today's date.
|
||||
"""
|
||||
from datetime import date
|
||||
|
||||
today = date.today()
|
||||
return today.strftime("%B %d, %Y")
|
||||
|
||||
|
||||
def render_template(data):
|
||||
"""Render the template using the given data.
|
||||
|
||||
|
@ -226,7 +241,9 @@ def render_template(data):
|
|||
environment.filters["make_it_underlined"] = make_it_underlined
|
||||
environment.filters["make_it_italic"] = make_it_italic
|
||||
|
||||
output_latex_file = template.render(design=data.design.options, cv=data.cv)
|
||||
output_latex_file = template.render(
|
||||
design=data.design.options, cv=data.cv, today=print_today()
|
||||
)
|
||||
|
||||
# Create an output file and write the rendered LaTeX code to it:
|
||||
output_file_path = os.path.join(os.getcwd(), "tests", "outputs", "test.tex")
|
||||
|
|
|
@ -99,7 +99,7 @@
|
|||
\newcommand{\placelastupdatedtext}{% \placetextbox{<horizontal pos>}{<vertical pos>}{<stuff>}
|
||||
\AddToShipoutPictureFG*{% Add <stuff> to current page foreground
|
||||
\put(\LenToUnit{\paperwidth-0.5cm},\LenToUnit{\paperheight-0.5cm}){\vtop{{\null}\makebox[0pt][c]{
|
||||
\small\color{gray}\emph{Last updated on \printdayon\today} \hspace{\widthof{Last updated on \printdayon\today}}}}}%
|
||||
\small\color{gray}\emph{Last updated on <<today>>} \hspace{\widthof{Last updated on <<today>>}}}}}%
|
||||
}%
|
||||
}%
|
||||
|
||||
|
|
Loading…
Reference in New Issue