Skip to content

Instantly share code, notes, and snippets.

@v0y4g3r
Created March 9, 2019 09:35
Show Gist options
  • Save v0y4g3r/a3e2dfc7fa14a90b844f911600a8a3d8 to your computer and use it in GitHub Desktop.
Save v0y4g3r/a3e2dfc7fa14a90b844f911600a8a3d8 to your computer and use it in GitHub Desktop.
gogs使用latex公式无法使用下标(与emphasis混淆)
#! /bin/bash
# set -x
cgd="$(git diff --cached --name-status | awk '$1 != "D" {print $2} '| tr -d '\r'| tr '\n' ' ')"
# echo "${cgd}"
for f in "${cgd[@]}";do
perl -i -ne 's/(?<!\\)_\{/\\_\{/g; print;' $f
backup_file="$(echo "$f" | sed 's/[[:space:]]*$//')".bak
# echo "${backup_file}"
if [ -f "${backup_file}" ]; then
rm "${backup_file}"
fi
done
git add --all
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment