@@ 12,16 12,10 @@ environment:
tasks:
- compile: |
cd $cv
- pdflatex -file-line-error -interaction nonstopmode document.tex > /dev/null
- biber document
- pdflatex -file-line-error -interaction nonstopmode document.tex > /dev/null
- texfot pdflatex -file-line-error -interaction nonstopmode document.tex
+ ./compile.sh document.tex
mv document.pdf ../cv_es.pdf
./switch-language.sh
- pdflatex -file-line-error -interaction nonstopmode document.tex > /dev/null
- biber document
- texfot pdflatex -file-line-error -interaction nonstopmode document.tex > /dev/null
- texfot pdflatex -file-line-error -interaction nonstopmode document.tex
+ ./compile.sh document.tex
mv document.pdf ../cv_en.pdf
- package: |
tar -cvz cv_*.pdf > site.tar.gz
@@ 1,6 1,6 @@
-#!/bin/bash
+#!/bin/sh
#
-# Copyright © 2018-2020 José Alberto Orejuela García (josealberto4444)
+# Copyright © 2018-2021 José Alberto Orejuela García (josealberto4444)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
@@ 15,85 15,112 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# If an expansion does not fit, give the empty list
-shopt -s nullglob
+reset_all_attributes='\e[0m'
+color_bright_red='\e[1;31m'
+color_bright_green='\e[1;32m'
+color_bright_yellow='\e[1;33m'
+color_bright_blue='\e[1;34m'
+# Standard version (not bright) without "1;", for example:
+# color_blue='\e[34m'
-NC='\033[0m'
-RED='\033[1;31m'
-GREEN='\033[1;32m'
-YELLOW='\033[1;33m'
-BLUE='\033[1;34m'
+IFS="$(printf '\n\t')"
-function buildpdf {
- inkscape -D $1 --export-type=pdf
+red() {
+ printf "${color_bright_red}%s${reset_all_attributes}\n" "$1"
}
-function plural {
+green() {
+ printf "${color_bright_green}%s${reset_all_attributes}\n" "$1"
+}
+
+yellow() {
+ printf "${color_bright_yellow}%s${reset_all_attributes}\n" "$1"
+}
+
+blue() {
+ printf "${color_bright_blue}%s${reset_all_attributes}\n" "$1"
+}
+
+buildpdf() {
+ inkscape -D "$1" --export-type=pdf
+}
+
+plural() {
message="$1"
- if [ "${message:0:2}" -ne "1 " ]; then
- if [ "${message: -1}" = "x" ]; then
+ if [ "$(printf '%s' "$message" | cut -c 1-2)" -ne "1 " ]; then
+ if [ "$(printf '%s' "$message" | rev | cut -c 1)" = "x" ]; then
message="${message}es"
else
message="${message}s"
fi
fi
- echo "$message"
+ printf '%s' "$message"
}
-# Check if all images are already built from svg, and build if not
-for svgfile in img/*.svg; do
- if [ $svgfile != "img/template.svg" ]; then
- pdffile=${svgfile%svg}pdf
- if [ ! -f $pdffile ]; then
- buildpdf $svgfile && echo -e "${BLUE}Built $pdffile${NC}"
- elif [ $svgfile -nt $pdffile ]; then
- buildpdf $svgfile && echo -e "${BLUE}Updated $pdffile${NC}"
+# If Inkscape is installed, check if all images are already built from svg, and
+# build if not
+if command -v inkscape > /dev/null; then
+ for svgfile in img/*.svg; do
+ if [ -e "$svgfile" ] && [ "$svgfile" != "img/template.svg" ]; then
+ pdffile="${svgfile%svg}pdf"
+ if [ ! -f "$pdffile" ]; then
+ buildpdf "$svgfile" && blue "Built $pdffile"
+ elif [ -n "$(find "$svgfile" -newer "$pdffile")" ]; then
+ buildpdf "$svgfile" && blue "Updated $pdffile"
+ fi
fi
- fi
-done
+ done
+else
+ yellow "Inkscape is not installed. Images will not be generated."
+fi
# Compile LaTeX document
-texfot pdflatex -file-line-error -interaction nonstopmode "$1" > /dev/null
-echo ""
-biber ${1%.tex}
-texfot pdflatex -file-line-error -interaction nonstopmode "$1" > /dev/null
-echo ""
-eval "$( (texfot pdflatex -file-line-error -interaction nonstopmode "$1") > >(readarray -t t_std; typeset -p t_std); t_ret=$?; typeset -p t_ret )"
-if [ "$t_ret" -ne 0 ]; then
- no_err=0
- for line in "${t_std[@]}"; do
- if [ "${line:0:2}" = "./" ]; then
- no_err=$((no_err + 1))
- echo -ne "${RED}"; echo -n "${line}"; echo -e "${NC}"
+pdflatex -file-line-error -interaction nonstopmode "$1" > /dev/null
+printf '\n'
+biber "${1%.tex}"
+pdflatex -file-line-error -interaction nonstopmode "$1" > /dev/null
+printf '\n'
+# Set the separator to be the newline so we can handle the output of the
+# command line by line
+IFS='
+'
+# It cannot be defined as IFS="$(printf '\n')" because $() command substitution
+# removes all trailing newline characters.
+messages="$(texfot pdflatex -file-line-error -interaction nonstopmode "$1")"
+exit_value="$?"
+
+if [ "$exit_value" -ne 0 ]; then
+ # Variable counting errors
+ nerr=0
+ for line in $messages; do
+ if [ "$(printf '%s' "$line" | cut -c 1-2)" = './' ]; then
+ nerr=$((nerr + 1))
+ red "$line"
else
- echo "$line"
+ printf '%s\n' "$line"
fi
done
- message=$(plural "$no_err error")
- echo -e "\n${RED}${message}${NC}"
+ red "$(plural "$nerr error")"
else
- if [ "${#t_std[@]}" -gt 3 ]; then
- no_warn=0 #$(("${#t_std[@]}" - 3))
- no_badbox=0
- no_line=1
- for line in "${t_std[@]}"; do
- if [ "$no_line" -ne 1 ] && [ "$no_line" -ne 2 ] && [ "$no_line" -ne "${#t_std[@]}" ]; then
- if [ "${line:0:15}" = "LaTeX Warning: " ]; then
- no_warn=$((no_warn + 1))
- else
- no_badbox=$((no_badbox + 1))
- fi
- echo -ne "${YELLOW}"; echo -n "${line}"; echo -e "${NC}"
- else
- echo "$line"
- fi
- no_line=$((no_line + 1))
- done
- message=$(plural "${no_warn} warning")", "$(plural "${no_badbox} badbox")
- echo -e "\n${YELLOW}${message}${NC}"
+ # Variable counting warnings
+ nwarn=0
+ # Variable counting badboxes
+ nbb=0
+ for line in $messages; do
+ if printf '%s' "$line" | grep "[Ww]arning" > /dev/null; then
+ nwarn=$((nwarn + 1))
+ yellow "$line"
+ elif printf '%s' "$line" | grep "full.*box" > /dev/null; then
+ nbb=$((nbb + 1))
+ yellow "$line"
+ else
+ printf '%s\n' "$line"
+ fi
+ done
+ if [ "$nwarn" -eq 0 ] && [ "$nbb" -eq 0 ]; then
+ green "0 errors, 0 warnings, 0 badboxes"
else
- printf '%s\n' "${t_std[@]}"
- echo -e "\n${GREEN}0 errors, 0 warnings, 0 badboxes${NC}"
+ yellow "$(plural "$nwarn warning"), $(plural "$nbb badbox")"
fi
fi