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...
|
||||
"""
|
||||
if value is None:
|
||||
if not isinstance(value, str):
|
||||
raise ValueError("markdown_to_latex should only be used on strings!")
|
||||
|
||||
# convert links
|
||||
|
@ -45,17 +45,24 @@ if __name__ == "__main__":
|
|||
|
||||
return value
|
||||
|
||||
def is_markdown(value: str) -> bool:
|
||||
def markdown_url_to_url(value: str) -> bool:
|
||||
"""
|
||||
To be continued...
|
||||
"""
|
||||
if re.search(r"\[(.*)\]\((.*?)\)", value) is not None:
|
||||
return True
|
||||
if not isinstance(value, str):
|
||||
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:
|
||||
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["is_markdown"] = is_markdown
|
||||
environment.filters["markdown_url_to_url"] = markdown_url_to_url
|
||||
|
||||
environment.block_start_string = "((*"
|
||||
environment.block_end_string = "*))"
|
||||
|
|
|
@ -260,14 +260,25 @@ class Event(BaseModel):
|
|||
|
||||
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
|
||||
|
||||
@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
|
||||
@cached_property
|
||||
def highlight_strings(self) -> list[SpellCheckedString]:
|
||||
|
@ -286,23 +297,28 @@ class Event(BaseModel):
|
|||
"""
|
||||
To be continued...
|
||||
"""
|
||||
url = str(self.url)
|
||||
|
||||
if "github" in url:
|
||||
text_url = "view on GitHub"
|
||||
elif "linkedin" in url:
|
||||
text_url = "view on LinkedIn"
|
||||
elif "instagram" in url:
|
||||
text_url = "view on Instagram"
|
||||
if self.url is None:
|
||||
return None
|
||||
else:
|
||||
text_url = "view on my website"
|
||||
url = str(self.url)
|
||||
|
||||
markdown_url = f"[{text_url}]({url})"
|
||||
if "github" in url:
|
||||
text_url = "view on GitHub"
|
||||
elif "linkedin" in url:
|
||||
text_url = "view on LinkedIn"
|
||||
elif "instagram" in url:
|
||||
text_url = "view on Instagram"
|
||||
elif "YOUTUBE" in url:
|
||||
text_url = "view on YouTube"
|
||||
else:
|
||||
text_url = "view on my website"
|
||||
|
||||
return markdown_url
|
||||
markdown_url = f"[{text_url}]({url})"
|
||||
|
||||
return markdown_url
|
||||
|
||||
|
||||
class OneLineEntry(BaseModel):
|
||||
class OneLineEntry(Event):
|
||||
# 1) Mandotory user inputs:
|
||||
name: str
|
||||
details: str
|
||||
|
@ -371,6 +387,7 @@ class CurriculumVitae(BaseModel):
|
|||
education: list[EducationEntry] = None
|
||||
work_experience: list[ExperienceEntry] = None
|
||||
academic_projects: list[NormalEntry] = None
|
||||
personal_projects: list[NormalEntry] = None
|
||||
certificates: list[NormalEntry] = None
|
||||
extracurricular_activities: list[ExperienceEntry] = None
|
||||
test_scores: list[OneLineEntry] = None
|
||||
|
|
|
@ -99,20 +99,24 @@
|
|||
<<section_contents(data = cv.education, entry_type="education")|indent(4)>>
|
||||
|
||||
\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_contents(data = cv.academic_projects, entry_type="normal")|indent(4)>>
|
||||
|
||||
\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_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_contents(data = cv.skills, entry_type="one_line")|indent(4)>>
|
||||
\section{Personal Projects}
|
||||
<<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}
|
|
@ -35,19 +35,19 @@
|
|||
\end{tabularx}
|
||||
((* 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⟩} #))
|
||||
((# width: \textwidth #))
|
||||
((# preamble: first column, second column #))
|
||||
((# first column:: X; variable width, ragged left column #))
|
||||
((# second column: R{<<design.date_and_location_width>>}; constant width ragged right column #))
|
||||
\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 *))
|
||||
((* 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>>
|
||||
((* elif url|is_markdown *))
|
||||
\textbf{<<name>>}, <<url|markdown_to_latex>>
|
||||
((* endif *))
|
||||
((* else *))
|
||||
\textbf{<<name>>}
|
||||
|
@ -58,15 +58,23 @@
|
|||
\end{tabularx}
|
||||
((* 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⟩} #))
|
||||
((# width: \textwidth #))
|
||||
((# preamble: first column, second column #))
|
||||
((# first column:: X; variable width, ragged left column #))
|
||||
((# second column: R{<<design.date_and_location_width>>}; constant width ragged right column #))
|
||||
\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>>
|
||||
|
||||
((* endif *))
|
||||
\vspace{\YMarginBetweenEntries}
|
||||
\setlength{\leftskip}{0cm}
|
||||
((* endmacro *))
|
|
@ -1,35 +1,40 @@
|
|||
((* 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 *))
|
||||
((* 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" *))
|
||||
<<entry["education"](
|
||||
study_type=value.study_type,
|
||||
institution=value.institution,
|
||||
area=value.area,
|
||||
highlights=value.highlight_strings,
|
||||
date_and_location_strings=value.date_and_location_strings
|
||||
date_and_location_strings=date_and_location_strings
|
||||
)|indent(4)>>
|
||||
((* elif entry_type == "experience" *))
|
||||
<<entry["experience"](
|
||||
company=value.company,
|
||||
position=value.position,
|
||||
highlights=value.highlight_strings,
|
||||
date_and_location_strings=value.date_and_location_strings
|
||||
date_and_location_strings=date_and_location_strings
|
||||
)|indent(4)>>
|
||||
((* elif entry_type == "normal" *))
|
||||
<<entry["normal"](
|
||||
name=value.name,
|
||||
highlights=value.highlight_strings,
|
||||
date_and_location_strings=value.date_and_location_strings,
|
||||
url=value.markdown_url,
|
||||
date_and_location_strings=date_and_location_strings,
|
||||
markdown_url=value.markdown_url,
|
||||
text_url=text_url,
|
||||
)|indent(4)>>
|
||||
((* elif entry_type == "one_line" *))
|
||||
<<entry["one_line"](
|
||||
name=value.name,
|
||||
details=value.details,
|
||||
url=value.markdown_url,
|
||||
markdown_url=value.markdown_url,
|
||||
text_url=text_url,
|
||||
)|indent(4)>>
|
||||
((* endif *))
|
||||
|
|
Loading…
Reference in New Issue