Skip to content

Commit

Permalink
Fixing bug in wrapping logic
Browse files Browse the repository at this point in the history
  • Loading branch information
WGUNDERWOOD committed May 4, 2024
1 parent 9f6b3c1 commit 81a9c1e
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 12 deletions.
8 changes: 4 additions & 4 deletions extra/latex.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ echo $DIR
for file in *_in.tex; do
f=$(basename $file _in.tex)
echo $f
latexmk -pdf -quiet -rc-report- ${f}_in.tex >/dev/null 2>&1
latexmk -pdf -quiet -rc-report- ${f}_out.tex >/dev/null 2>&1
pdftotext ${f}_in.pdf >/dev/null 2>&1
pdftotext ${f}_out.pdf >/dev/null 2>&1
latexmk -pdf ${f}_in.tex
latexmk -pdf ${f}_out.tex
pdftotext ${f}_in.pdf
pdftotext ${f}_out.pdf
diff -u ${f}_in.txt ${f}_out.txt | diff-so-fancy
done
97 changes: 97 additions & 0 deletions extra/wgu-cv.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
%! TeX root = WGUnderwood.tex

% class
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{wgu-cv}

% packages
\LoadClass[10pt]{article}
\RequirePackage[margin=1in,top=0.9in]{geometry}
\RequirePackage{hyperref}
%\RequirePackage{fontspec}
\RequirePackage{microtype}
\RequirePackage{fancyhdr}
\RequirePackage{enumitem}
\RequirePackage{ifthen}

% variables
\def\yourname#1{\def\@yourname{#1}}
\def\youraddress#1{\def\@youraddress{#1}}
\def\youremail#1{\def\@youremail{#1}}
\def\yourwebsite#1{\def\@yourwebsite{#1}}

% settings
%\setmainfont{Libre Baskerville}[Scale=0.9]
%\setmonofont{Source Code Pro}[Scale=0.97]
\geometry{a4paper}
\setlength\parindent{0pt}
\bibliographystyle{abbrvnat}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\cfoot{\thepage}
\rfoot{\today}
\setlist{
leftmargin=0.5cm,
topsep=0cm,
partopsep=0cm,
parsep=-0.04cm, % item spacing
before=\vspace{0.12cm},
after=\vspace{0.08cm},
}

% arxiv
\newcommand{\arxiv}[1]{%
\href{https://arxiv.org/abs/#1}{%
\texttt{arXiv{:}{\allowbreak}#1}}%
}

% github
\newcommand{\github}[1]{%
GitHub: \href{https://github.com/#1}{%
\texttt{#1}}%
}

% title
\renewcommand{\maketitle}{%
\vspace*{-1.2cm}%
\begin{center}%
\begin{huge}%
\@yourname \\
\end{huge}%
\vspace{0.5cm}%
\@youraddress \\
\vspace{0.16cm}%
\begin{minipage}{0.45\textwidth}%
\centering%
\href{mailto:\@youremail}{\nolinkurl{\@youremail}}%
\end{minipage}%
\begin{minipage}{0.45\textwidth}%
\centering%
\href{https://\@yourwebsite}{\nolinkurl{\@yourwebsite}}%
\end{minipage}
\end{center}%
}

% section
\renewcommand{\section}[1]{%
\vspace{0.3cm}%
\par\hbox{\large\textbf{#1}\strut}%
\vspace{-0.25cm}%
\rule{\textwidth}{0.8pt}%
\vspace{-0.15cm}%
}

% subsection
\renewcommand{\subsection}[2]{%
\vspace{0.30cm}%
\textbf{#1}%
\hfill{#2}%
\vspace{0.03cm}%
}

% subsubsection
\renewcommand{\subsubsection}[1]{%
\linebreak
\textit{#1}%
\vspace{0.05cm}%
}
1 change: 0 additions & 1 deletion src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub fn format_file(file: &str, debug: bool) -> String {

let mut wrap_tries = 0;
while needs_wrap(&new_file) && wrap_tries < MAX_WRAP_TRY {
dbg!("wrapping");
wrap_tries += 1;
new_file = wrap(&new_file);
new_file = remove_trailing_spaces(&new_file);
Expand Down
13 changes: 6 additions & 7 deletions src/wrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ pub fn line_needs_wrap(line: &str) -> bool {

pub fn find_wrap_point(line: &str) -> Option<usize> {
let mut wrap_point: Option<usize> = None;
let mut after_non_space = false;
let mut after_char = false;
for i in 0..WRAP {
let char_is_space: bool = line.chars().nth(i) == Some(' ');
if char_is_space {
if after_non_space {
if line.chars().nth(i) == Some(' ') {
if after_char {
wrap_point = Some(i);
}
} else {
after_non_space = true;
} else if line.chars().nth(i) != Some('%') {
after_char = true;
}
}
wrap_point
Expand Down Expand Up @@ -54,7 +53,7 @@ pub fn wrap_line(line: &str) -> String {
None => {
can_wrap = false;
println!("long line cannot be wrapped!");
println!("{}", line);
println!("{}", remaining_line);
}
}
}
Expand Down

0 comments on commit 81a9c1e

Please sign in to comment.