feat: improved latex generator script

This commit is contained in:
Yandrik 2022-05-15 22:14:25 +02:00
parent 0efddc3457
commit b17c8b97d4

View File

@ -18,8 +18,12 @@ echo "Generating modified Markdown file..."
#prefix every \ with a \
sed -i -e 's/\\\\ *$/\\\\\\\\/g' "$NEWNAME"
# prefix every _ with an \
sed -i -e 's/_/\\_/g' "$NEWNAME"
bat "$NEWNAME"
# prefix every individual _ with an \
sed -i -e 's/_([^_])/\\_\1/g' "$NEWNAME"
bat "$NEWNAME"
# remove tags section at the front
sed -i -e 's/tags:.*//g' "$NEWNAME"
@ -28,11 +32,32 @@ sed -i -e 's/---$//g' "$NEWNAME"
#remove markdown links
sed -i -e 's/\[.*\](.*)//g' "$NEWNAME"
# remove html tags
# remove code block lang declaration
sed -i -e 's/```.*/```/g' "$NEWNAME"
bat "$NEWNAME"
# add newlines around code block declaration
sed -i -e 's/``` *$/\n```\n/g' "$NEWNAME"
bat "$NEWNAME"
# replace special HTML tags
sed -i -e 's/<div id="page-break-after"\/>/\\pagebreak/g' "$NEWNAME"
sed -i -e 's/<br>/\\newline/g' "$NEWNAME"
# remove html tags
sed -i -e 's/<[a-zA-Z ]*>\(.*\)<\/[a-zA-Z =]*>/\1/g' "$NEWNAME"
sed -i -e 's/<.*\/>//g' "$NEWNAME"
sed -i -e 's/<.*>//g' "$NEWNAME"
# replace arrows
sed -i -e 's/->/$\\rightarrow$/g' "$NEWNAME"
sed -i -e 's/<-/$\\leftarrow$/g' "$NEWNAME"
sed -i -e 's/=>/$\\Rightarrow$/g' "$NEWNAME"
sed -i -e 's/<=/$\\Leftarrow$/g' "$NEWNAME"
bat "$NEWNAME"
echo "Generating LaTeX file..."
echo "\documentclass[a4paper, 11pt]{article}