Skip to content

Commit

Permalink
feat: Adds a new command for interprolating md-style links in pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
Lissy93 committed Aug 1, 2024
1 parent dba91a0 commit 110633b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
7 changes: 6 additions & 1 deletion lib/generate.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import argparse
import json
import re
import logging
import os
import yaml
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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', {}),
Expand Down
15 changes: 7 additions & 8 deletions template.jinja
Original file line number Diff line number Diff line change
@@ -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 <http://www.posquit0.com>
%
% 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/]
Expand Down Expand Up @@ -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 %}
Expand Down Expand Up @@ -148,6 +143,10 @@
{%- endfor %}
\end{cvhonors}
{% endif %}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Footer
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Add the footer link at the end of the document
\vspace{10mm}
\begin{flushleft}
Expand Down

0 comments on commit 110633b

Please sign in to comment.