@ -15,7 +15,7 @@ function worddiv --description "Interact with TeX and babel (LaTeX) to show word
# -f : scope our variable to the function
set -f project_path ~/.config/fish /conf.d/worddiv
set -f tmpdir $project_path /.cache/tempdir_( date -Ins )
mkdir -p " $tmpdir " || echo "Unable to create temporary directory!"
# mkdir -p " $tmpdir " || echo "Unable to create temporary directory!" # move this to inside the while loop
set -f template_filename latex-hyphenation-template.tex
set -f expression_filename latex-hyphenation-target.tex
set -f secondary_filename latex-hyphenation-target-british.tex
@ -24,9 +24,9 @@ function worddiv --description "Interact with TeX and babel (LaTeX) to show word
# welcome message
set -f tex_version ( tex -version | head -n 1 )
set -f latex_version ( latex -version | head -n 1 )
echo " Let’s query " ; set_color yellow ; echo -n " $tex_version " ; set_color normal
printf "\n Let’s query " ; set_color yellow ; echo -n " $tex_version " ; set_color normal
echo " and " ; set_color yellow ; echo -n " $latex_version " ; set_color normal ; echo " !"
echo -e '\nEnter an expression to see its hyphenation, or ‘q’ to quit.\n'
printf '\nEnter an expression to see its hyphenation, or ‘q’ to quit.\n \n'
# set languages
set -f language american
@ -35,30 +35,35 @@ function worddiv --description "Interact with TeX and babel (LaTeX) to show word
# interact
set -f expression ""
while test $expression != "q"
read -f --prompt hyphenation_prompt expression
if test ! -e $tmpdir
mkdir -p " $tmpdir " || echo "Unable to create temporary directory!"
end
if test $expression != "q"
## latex+babel
# generate input and output
# grab a copy of the template
cp $project_path /$template_filename $tmpdir /
# modify the template, inserting our two variables
# for now, $language just = american
sed " s/language/ $language /g " $tmpdir /$template_filename |
sed " s/expression/ $expression /g " |
# modify template: uncomment its \i nput ushyphex line so that
# also uncomment its \i nput ushyphex line so that
# the exceptions list for AE will be included
# output to a new file
sed "s/% \\\input/\\\input/g" > $tmpdir /$expression_filename
# let's check and see if british english divides this expression differently
# modify the template with a different language
# for now, $secondary_language just = british
# output to a new file
sed " s/language/ $secondary_language /g " $tmpdir /$template_filename |
sed " s/expression/ $expression /g " > $tmpdir /$secondary_filename
## operate on the files and filter the output
# american
set -f babel_output (
latex -draftmode $tmpdir /$expression_filename |
@ -69,7 +74,6 @@ function worddiv --description "Interact with TeX and babel (LaTeX) to show word
latex -draftmode $tmpdir /$secondary_filename |
grep "\\[\\] .OT1" | sed 's_\\[\\] .OT1/cmr/m/n/10 __' )
## tex+showhyphens
# generate output
set -f tex_untrimmed ( echo -e " \showhyphens{ $expression } " |
@ -102,14 +106,11 @@ function worddiv --description "Interact with TeX and babel (LaTeX) to show word
set_color normal ; echo -e " $babel_output_british \n "
end
end
end
end
echo -e "\nQuitting...\n"
# clean up
if -e $tmpdir
if test -e $tmpdir
rm -r $tmpdir
end
end