Skip to content

Instantly share code, notes, and snippets.

@anthonygelibert
Created May 28, 2016 21:04
Show Gist options
  • Save anthonygelibert/a1abbe6af3f9552af7e3397db63efba4 to your computer and use it in GitHub Desktop.
Save anthonygelibert/a1abbe6af3f9552af7e3397db63efba4 to your computer and use it in GitHub Desktop.
Clean LaTeX files
#!/usr/bin/env sh
for i in "$@"; do
sed -i'.tmp'\
-e 's/« /\\og{}/g' \
-e 's/ »/\\fg{}/g' \
-e 's/ ?/~?/g' \
-e 's/ :/~:/g' \
-e 's/ ;/~;/g' \
-e 's/« /\\og{}/g' \
-e 's/« /\\og{}/g' \
-e 's/« /\\og{}/g' \
-e 's/\\og /\\og{}/g' \
-e 's/\\og{} /\\og{}/g' \
-e 's/ \\fg\./\\fg{}\./g' \
-e 's/ \\fg~/\\fg{}~/g' \
-e 's/ \\fg,/\\fg{},/g' \
-e 's/ \\fg /\\fg{} /g' \
-e 's/ \\fg{}/\\fg{}/g' \
-e 's/ »/\\fg{}/g' \
-e 's/ »/\\fg{}/g' \
-e 's/ »/\\fg{}/g' \
-e 's/ \\fg{}/\\fg{}/g' \
-e 's/…/\\dots/g'\
-e 's/ç/\\c c/g'\
-e 's/chaîne/chaine/g'\
-e 's/Chaîne/Chaine/g'\
-e 's/œ/\\oe{}/g' \
-e "s/’/'/g" \
-e "s/’/'/g" \
-e 's/—/---/g' \
-e 's/–/--/g' \
-e 's/ ,/,/g' \
-e 's/( /(/g' \
-e 's/ )/)/g' \
-e 's/[ \t]*$//' \
-e 's/ \\ref/~\\ref/g' \
-e 's/ \\footnote/\\footnote/g' \
-e 's/\\nline$/\\nline{}/g' \
-e 's_"\([a-zA-Zàâéèäê]*\)"_\\og{}\1\\fg{}_g' "$i"
[[ $? -eq 0 ]] && rm "$i.tmp" || mv "$i.tmp" "$i"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment