mirror of https://github.com/eyhc1/rendercv.git
make time span optional
This commit is contained in:
parent
6c7e425af2
commit
e0ae4a60d0
|
@ -31,7 +31,7 @@ if __name__ == "__main__":
|
||||||
"""
|
"""
|
||||||
To be continued...
|
To be continued...
|
||||||
"""
|
"""
|
||||||
if value is None:
|
if not isinstance(value, str):
|
||||||
raise ValueError("markdown_to_latex should only be used on strings!")
|
raise ValueError("markdown_to_latex should only be used on strings!")
|
||||||
|
|
||||||
# convert links
|
# convert links
|
||||||
|
@ -45,17 +45,24 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def is_markdown(value: str) -> bool:
|
def markdown_url_to_url(value: str) -> bool:
|
||||||
"""
|
"""
|
||||||
To be continued...
|
To be continued...
|
||||||
"""
|
"""
|
||||||
if re.search(r"\[(.*)\]\((.*?)\)", value) is not None:
|
if not isinstance(value, str):
|
||||||
return True
|
raise ValueError("markdown_to_latex should only be used on strings!")
|
||||||
|
|
||||||
|
link = re.search(r"\[(.*)\]\((.*?)\)", value)
|
||||||
|
if link is not None:
|
||||||
|
url = link.groups()[1]
|
||||||
|
return url
|
||||||
else:
|
else:
|
||||||
return False
|
raise ValueError(
|
||||||
|
"markdown_url_to_url should only be used on markdown links!"
|
||||||
|
)
|
||||||
|
|
||||||
environment.filters["markdown_to_latex"] = markdown_to_latex
|
environment.filters["markdown_to_latex"] = markdown_to_latex
|
||||||
environment.filters["is_markdown"] = is_markdown
|
environment.filters["markdown_url_to_url"] = markdown_url_to_url
|
||||||
|
|
||||||
environment.block_start_string = "((*"
|
environment.block_start_string = "((*"
|
||||||
environment.block_end_string = "*))"
|
environment.block_end_string = "*))"
|
||||||
|
|
|
@ -260,14 +260,25 @@ class Event(BaseModel):
|
||||||
|
|
||||||
date_and_location_strings.append(f"{start_date} to {end_date}")
|
date_and_location_strings.append(f"{start_date} to {end_date}")
|
||||||
|
|
||||||
class_names_that_uses_time_span_strings = [
|
|
||||||
"ExperienceEntry",
|
|
||||||
]
|
|
||||||
if self.__class__.__name__ in class_names_that_uses_time_span_strings:
|
|
||||||
date_and_location_strings.append(f"{time_span_string}")
|
date_and_location_strings.append(f"{time_span_string}")
|
||||||
|
|
||||||
return date_and_location_strings
|
return date_and_location_strings
|
||||||
|
|
||||||
|
@computed_field
|
||||||
|
@cached_property
|
||||||
|
def date_and_location_strings_without_time_span(self) -> list[str]:
|
||||||
|
strings_without_time_span = self.date_and_location_strings
|
||||||
|
for string in strings_without_time_span:
|
||||||
|
if (
|
||||||
|
"years" in string
|
||||||
|
or "months" in string
|
||||||
|
or "year" in string
|
||||||
|
or "month" in string
|
||||||
|
):
|
||||||
|
strings_without_time_span.remove(string)
|
||||||
|
|
||||||
|
return strings_without_time_span
|
||||||
|
|
||||||
@computed_field
|
@computed_field
|
||||||
@cached_property
|
@cached_property
|
||||||
def highlight_strings(self) -> list[SpellCheckedString]:
|
def highlight_strings(self) -> list[SpellCheckedString]:
|
||||||
|
@ -286,6 +297,9 @@ class Event(BaseModel):
|
||||||
"""
|
"""
|
||||||
To be continued...
|
To be continued...
|
||||||
"""
|
"""
|
||||||
|
if self.url is None:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
url = str(self.url)
|
url = str(self.url)
|
||||||
|
|
||||||
if "github" in url:
|
if "github" in url:
|
||||||
|
@ -294,6 +308,8 @@ class Event(BaseModel):
|
||||||
text_url = "view on LinkedIn"
|
text_url = "view on LinkedIn"
|
||||||
elif "instagram" in url:
|
elif "instagram" in url:
|
||||||
text_url = "view on Instagram"
|
text_url = "view on Instagram"
|
||||||
|
elif "YOUTUBE" in url:
|
||||||
|
text_url = "view on YouTube"
|
||||||
else:
|
else:
|
||||||
text_url = "view on my website"
|
text_url = "view on my website"
|
||||||
|
|
||||||
|
@ -302,7 +318,7 @@ class Event(BaseModel):
|
||||||
return markdown_url
|
return markdown_url
|
||||||
|
|
||||||
|
|
||||||
class OneLineEntry(BaseModel):
|
class OneLineEntry(Event):
|
||||||
# 1) Mandotory user inputs:
|
# 1) Mandotory user inputs:
|
||||||
name: str
|
name: str
|
||||||
details: str
|
details: str
|
||||||
|
@ -371,6 +387,7 @@ class CurriculumVitae(BaseModel):
|
||||||
education: list[EducationEntry] = None
|
education: list[EducationEntry] = None
|
||||||
work_experience: list[ExperienceEntry] = None
|
work_experience: list[ExperienceEntry] = None
|
||||||
academic_projects: list[NormalEntry] = None
|
academic_projects: list[NormalEntry] = None
|
||||||
|
personal_projects: list[NormalEntry] = None
|
||||||
certificates: list[NormalEntry] = None
|
certificates: list[NormalEntry] = None
|
||||||
extracurricular_activities: list[ExperienceEntry] = None
|
extracurricular_activities: list[ExperienceEntry] = None
|
||||||
test_scores: list[OneLineEntry] = None
|
test_scores: list[OneLineEntry] = None
|
||||||
|
|
|
@ -99,20 +99,24 @@
|
||||||
<<section_contents(data = cv.education, entry_type="education")|indent(4)>>
|
<<section_contents(data = cv.education, entry_type="education")|indent(4)>>
|
||||||
|
|
||||||
\section{Work Experience}
|
\section{Work Experience}
|
||||||
<<section_contents(data = cv.work_experience, entry_type="experience")|indent(4)>>
|
<<section_contents(data = cv.work_experience, entry_type="experience", disableTimeSpan=False)|indent(4)>>
|
||||||
|
|
||||||
\section{Academic Projects}
|
\section{Academic Projects}
|
||||||
<<section_contents(data = cv.academic_projects, entry_type="normal")|indent(4)>>
|
<<section_contents(data = cv.academic_projects, entry_type="normal")|indent(4)>>
|
||||||
|
|
||||||
\section{Certificates}
|
\section{Certificates}
|
||||||
<<section_contents(data = cv.certificates, entry_type="normal", text_url="Course certificate")|indent(4)>>
|
<<section_contents(data = cv.certificates, entry_type="normal", text_url="View the certificate")|indent(4)>>
|
||||||
|
|
||||||
|
|
||||||
\section{Skills}
|
\section{Skills}
|
||||||
<<section_contents(data = cv.skills, entry_type="one_line")|indent(4)>>
|
<<section_contents(data = cv.skills, entry_type="one_line")|indent(4)>>
|
||||||
|
|
||||||
|
\section{Test Scores}
|
||||||
|
<<section_contents(data = cv.test_scores, entry_type="one_line", text_url="View the score report")|indent(4)>>
|
||||||
|
|
||||||
\section{Skills}
|
\section{Personal Projects}
|
||||||
<<section_contents(data = cv.skills, entry_type="one_line")|indent(4)>>
|
<<section_contents(data = cv.personal_projects, entry_type="normal")|indent(4)>>
|
||||||
|
|
||||||
|
\section{Extracurricular Activities}
|
||||||
|
<<section_contents(data = cv.extracurricular_activities, entry_type="experience")|indent(4)>>
|
||||||
|
|
||||||
\end{document}
|
\end{document}
|
|
@ -35,19 +35,19 @@
|
||||||
\end{tabularx}
|
\end{tabularx}
|
||||||
((* endmacro *))
|
((* endmacro *))
|
||||||
|
|
||||||
((* macro normal(name, highlights, date_and_location_strings, url, text_url=none)*))
|
((* macro normal(name, highlights, date_and_location_strings, markdown_url=none, text_url=none)*))
|
||||||
((# \begin{tabularx}{⟨width⟩}[⟨pos⟩]{⟨preamble⟩} #))
|
((# \begin{tabularx}{⟨width⟩}[⟨pos⟩]{⟨preamble⟩} #))
|
||||||
((# width: \textwidth #))
|
((# width: \textwidth #))
|
||||||
((# preamble: first column, second column #))
|
((# preamble: first column, second column #))
|
||||||
((# first column:: X; variable width, ragged left column #))
|
((# first column:: X; variable width, ragged left column #))
|
||||||
((# second column: R{<<design.date_and_location_width>>}; constant width ragged right column #))
|
((# second column: R{<<design.date_and_location_width>>}; constant width ragged right column #))
|
||||||
\begin{tabularx}{\textwidth}{X R{<<design.date_and_location_width>>}}
|
\begin{tabularx}{\textwidth}{X R{<<design.date_and_location_width>>}}
|
||||||
((* if url is not none *))
|
((* if markdown_url is not none *))
|
||||||
((* if text_url is not none *))
|
((* if text_url is not none *))
|
||||||
((* set markdown_url = "["+text_url+"]("+ str(url) +")" *))
|
((* set markdown_url = "["+text_url+"]("+ markdown_url|markdown_url_to_url +")" *))
|
||||||
|
\textbf{<<name>>}, <<markdown_url|markdown_to_latex>>
|
||||||
|
((* else *))
|
||||||
\textbf{<<name>>}, <<markdown_url|markdown_to_latex>>
|
\textbf{<<name>>}, <<markdown_url|markdown_to_latex>>
|
||||||
((* elif url|is_markdown *))
|
|
||||||
\textbf{<<name>>}, <<url|markdown_to_latex>>
|
|
||||||
((* endif *))
|
((* endif *))
|
||||||
((* else *))
|
((* else *))
|
||||||
\textbf{<<name>>}
|
\textbf{<<name>>}
|
||||||
|
@ -58,15 +58,23 @@
|
||||||
\end{tabularx}
|
\end{tabularx}
|
||||||
((* endmacro *))
|
((* endmacro *))
|
||||||
|
|
||||||
((* macro one_line(name, details, url, text_url=none)*))
|
((* macro one_line(name, details, markdown_url=none, text_url=none)*))
|
||||||
((# \begin{tabularx}{⟨width⟩}[⟨pos⟩]{⟨preamble⟩} #))
|
((# \begin{tabularx}{⟨width⟩}[⟨pos⟩]{⟨preamble⟩} #))
|
||||||
((# width: \textwidth #))
|
((# width: \textwidth #))
|
||||||
((# preamble: first column, second column #))
|
((# preamble: first column, second column #))
|
||||||
((# first column:: X; variable width, ragged left column #))
|
((# first column:: X; variable width, ragged left column #))
|
||||||
((# second column: R{<<design.date_and_location_width>>}; constant width ragged right column #))
|
((# second column: R{<<design.date_and_location_width>>}; constant width ragged right column #))
|
||||||
\setlength{\leftskip}{0.2cm}
|
\setlength{\leftskip}{0.2cm}
|
||||||
|
((* if markdown_url is not none *))
|
||||||
|
((* if text_url is not none *))
|
||||||
|
((* set markdown_url = "["+text_url+"]("+ markdown_url|markdown_url_to_url +")" *))
|
||||||
|
\textbf{<<name>>:} <<details>> (<<markdown_url|markdown_to_latex>>)
|
||||||
|
((* else *))
|
||||||
|
\textbf{<<name>>:} <<details>> (<<markdown_url|markdown_to_latex>>)
|
||||||
|
((* endif *))
|
||||||
|
((* else *))
|
||||||
\textbf{<<name>>:} <<details>>
|
\textbf{<<name>>:} <<details>>
|
||||||
|
((* endif *))
|
||||||
\vspace{\YMarginBetweenEntries}
|
\vspace{\YMarginBetweenEntries}
|
||||||
\setlength{\leftskip}{0cm}
|
\setlength{\leftskip}{0cm}
|
||||||
((* endmacro *))
|
((* endmacro *))
|
|
@ -1,35 +1,40 @@
|
||||||
((* import "components/entry.tex.j2" as entry with context *))
|
((* import "components/entry.tex.j2" as entry with context *))
|
||||||
|
|
||||||
((* macro section_contents(data, entry_type, text_url=none)*))
|
((* macro section_contents(data, entry_type, text_url=none, disableTimeSpan=True)*))
|
||||||
((* for value in data *))
|
((* for value in data *))
|
||||||
|
((* if disableTimeSpan *))
|
||||||
|
((* set date_and_location_strings = value.date_and_location_strings_without_time_span *))
|
||||||
|
((* else *))
|
||||||
|
((* set date_and_location_strings = value.date_and_location_strings *))
|
||||||
|
((* endif *))
|
||||||
((* if entry_type == "education" *))
|
((* if entry_type == "education" *))
|
||||||
<<entry["education"](
|
<<entry["education"](
|
||||||
study_type=value.study_type,
|
study_type=value.study_type,
|
||||||
institution=value.institution,
|
institution=value.institution,
|
||||||
area=value.area,
|
area=value.area,
|
||||||
highlights=value.highlight_strings,
|
highlights=value.highlight_strings,
|
||||||
date_and_location_strings=value.date_and_location_strings
|
date_and_location_strings=date_and_location_strings
|
||||||
)|indent(4)>>
|
)|indent(4)>>
|
||||||
((* elif entry_type == "experience" *))
|
((* elif entry_type == "experience" *))
|
||||||
<<entry["experience"](
|
<<entry["experience"](
|
||||||
company=value.company,
|
company=value.company,
|
||||||
position=value.position,
|
position=value.position,
|
||||||
highlights=value.highlight_strings,
|
highlights=value.highlight_strings,
|
||||||
date_and_location_strings=value.date_and_location_strings
|
date_and_location_strings=date_and_location_strings
|
||||||
)|indent(4)>>
|
)|indent(4)>>
|
||||||
((* elif entry_type == "normal" *))
|
((* elif entry_type == "normal" *))
|
||||||
<<entry["normal"](
|
<<entry["normal"](
|
||||||
name=value.name,
|
name=value.name,
|
||||||
highlights=value.highlight_strings,
|
highlights=value.highlight_strings,
|
||||||
date_and_location_strings=value.date_and_location_strings,
|
date_and_location_strings=date_and_location_strings,
|
||||||
url=value.markdown_url,
|
markdown_url=value.markdown_url,
|
||||||
text_url=text_url,
|
text_url=text_url,
|
||||||
)|indent(4)>>
|
)|indent(4)>>
|
||||||
((* elif entry_type == "one_line" *))
|
((* elif entry_type == "one_line" *))
|
||||||
<<entry["one_line"](
|
<<entry["one_line"](
|
||||||
name=value.name,
|
name=value.name,
|
||||||
details=value.details,
|
details=value.details,
|
||||||
url=value.markdown_url,
|
markdown_url=value.markdown_url,
|
||||||
text_url=text_url,
|
text_url=text_url,
|
||||||
)|indent(4)>>
|
)|indent(4)>>
|
||||||
((* endif *))
|
((* endif *))
|
||||||
|
|
Loading…
Reference in New Issue