Formula code in JupyterLab format$$ $$
To```math
Convert to specifications
#script
run.sh
filename=${1-'code.md'}
search $$
nl -ba $filename | grep "\$\\$" > TMP
num of iteration
nrow=(`wc TMP | awk '{print $1}'`)
get row number
array=($(cat TMP | awk '{print $1}'))
for i in `seq 1 ${nrow}`
do
echo ${array[$((i-1))]}
if [ $(( ${i} % 2 )) == 1 ]
then sed -ie "${array[$((i-1))]} s/\$\\$/\`\`\`math/g" $filename
else sed -ie "${array[$((i-1))]} s/\$\\$/\`\`\`/g" $filename
fi
done
rm TMP
#Example of use
./run.sh code.md
Recommended Posts