diff --git a/lib/generate.py b/lib/generate.py index 9d24b6f..899f189 100644 --- a/lib/generate.py +++ b/lib/generate.py @@ -1,5 +1,5 @@ import argparse -import json +import re import logging import os import yaml @@ -57,6 +57,10 @@ def latex_escape(text: str) -> str: } return ''.join(latex_special_chars.get(char, char) for char in text) +def markdown_to_latex(text): + link_pattern = re.compile(r'\[([^\]]+)\]\(([^)]+)\)') + return link_pattern.sub(r'\\href{\2}{\1}', text).replace('%', '\%') + def format_date(date_str: str) -> str: """ Formats a date string to 'Month Year'. If the format is unknown, returns the original string. @@ -88,6 +92,7 @@ def render_template(template_path: str, resume_data: dict) -> str: ) env.filters['latex_escape'] = latex_escape env.filters['format_date'] = format_date + env.filters['markdown_to_latex'] = markdown_to_latex template = env.get_template(os.path.basename(template_path)) return template.render( basics=resume_data.get('basics', {}), diff --git a/template.jinja b/template.jinja index af38435..bad8309 100644 --- a/template.jinja +++ b/template.jinja @@ -1,17 +1,12 @@ %!TEX TS-program = xelatex %!TEX encoding = UTF-8 Unicode -% Alicia's CV LaTeX Template -% -% This template is heaviliy inspired by: -% https://github.com/posquit0/Awesome-CV -% By Claud D. Park -% +% Alicia Sykes CV LaTeX Template %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Configuration %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Themes: Awesome-CV -\documentclass[]{awesome-cv} +\documentclass[]{resume-format} \usepackage{textcomp} %%% Override a directory location for fonts(default: 'fonts/') \fontdir[fonts/] @@ -88,7 +83,7 @@ \cvsection{Achievements} \begin{cvachievements} {%- for achievement in achivments %} - \item { {{ achievement | latex_escape }} } + \item { {{ achievement | markdown_to_latex | safe }} } {%- endfor %} \end{cvachievements} {% endif %} @@ -148,6 +143,10 @@ {%- endfor %} \end{cvhonors} {% endif %} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Footer +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Add the footer link at the end of the document \vspace{10mm} \begin{flushleft}