Skip to content

Merge pull request #17 from tomii9273/add_nukeari_8and1 #8

Merge pull request #17 from tomii9273/add_nukeari_8and1

Merge pull request #17 from tomii9273/add_nukeari_8and1 #8

name: Check Math Formula
on:
push:
branches:
- main
jobs:
check-math-formula:
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- uses: actions/checkout@v3
- name: Check
run: |
n_valid=0
for str in '^\$' '\$$' '\(\$' '\$\)' ' \$' '\$ '
do
# grep はヒットしなかった場合に終了ステータスが 1 になり、GitHub Actions がエラーで止まってしまうため、先に sed でヒットするかを確認している
exist=$(sed -n -E -e "/${str}/p" src/README.md)
if [ -n "$exist" ]; then
n_tmp=$(grep -o -E "${str}" src/README.md | wc -l)
n_valid=$((n_valid+n_tmp))
fi
echo "now n_valid: $n_valid"
done
echo "final n_valid: $n_valid"
n_all=$(grep -o '\$' src/README.md | wc -l)
echo "final n_all: $n_all"
if [ $n_all -ne $n_valid ]; then
echo "Error: Invalid math formula found."
exit 1
fi
echo "Success: All math formulas are valid."
shell: bash