diff --git a/rendercv/__main__.py b/rendercv/__main__.py index 5ce6cd5..80d439d 100644 --- a/rendercv/__main__.py +++ b/rendercv/__main__.py @@ -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 = "*))" diff --git a/rendercv/data_model.py b/rendercv/data_model.py index 7d9e361..80e1c15 100644 --- a/rendercv/data_model.py +++ b/rendercv/data_model.py @@ -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 diff --git a/rendercv/templates/classic/classic.tex.j2 b/rendercv/templates/classic/classic.tex.j2 index 5173900..03ee14d 100644 --- a/rendercv/templates/classic/classic.tex.j2 +++ b/rendercv/templates/classic/classic.tex.j2 @@ -99,20 +99,24 @@ <> \section{Work Experience} - <> + <> \section{Academic Projects} <> \section{Certificates} - <> - + <> \section{Skills} <> + \section{Test Scores} + <> - \section{Skills} - <> + \section{Personal Projects} + <> + + \section{Extracurricular Activities} + <> \end{document} \ No newline at end of file diff --git a/rendercv/templates/classic/components/entry.tex.j2 b/rendercv/templates/classic/components/entry.tex.j2 index 68c5fa3..51a2899 100644 --- a/rendercv/templates/classic/components/entry.tex.j2 +++ b/rendercv/templates/classic/components/entry.tex.j2 @@ -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{<>}; constant width ragged right column #)) \begin{tabularx}{\textwidth}{X R{<>}} - ((* 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{<>}, <> + ((* else *)) \textbf{<>}, <> - ((* elif url|is_markdown *)) - \textbf{<>}, <> ((* endif *)) ((* else *)) \textbf{<>} @@ -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{<>}; 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{<>:} <
> (<>) + ((* else *)) + \textbf{<>:} <
> (<>) + ((* endif *)) + ((* else *)) \textbf{<>:} <
> - + ((* endif *)) \vspace{\YMarginBetweenEntries} \setlength{\leftskip}{0cm} ((* endmacro *)) \ No newline at end of file diff --git a/rendercv/templates/classic/components/section_contents.tex.j2 b/rendercv/templates/classic/components/section_contents.tex.j2 index e0aca43..dd016ec 100644 --- a/rendercv/templates/classic/components/section_contents.tex.j2 +++ b/rendercv/templates/classic/components/section_contents.tex.j2 @@ -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" *)) <> ((* elif entry_type == "experience" *)) <> ((* elif entry_type == "normal" *)) <> ((* elif entry_type == "one_line" *)) <> ((* endif *))