feat: completed make_latex script
This commit is contained in:
parent
53d11c7bc3
commit
64f86314bf
@ -1,18 +1,43 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ ! -f "$1" ]; then
|
||||
echo "File $1 not found!"
|
||||
echo "Usage: make_latex.sh <markdown-file>"
|
||||
exit
|
||||
fi
|
||||
|
||||
NEWNAME=modified.md
|
||||
|
||||
echo "Preparing working dir..."
|
||||
rm -rf workdir
|
||||
mkdir workdir
|
||||
cp "$1" "workdir/$NEWNAME"
|
||||
cd workdir
|
||||
|
||||
echo "Generating modified Markdown file..."
|
||||
|
||||
# prefix every _ with an \
|
||||
sed -i -e 's/_/\\_/g' "$NEWNAME"
|
||||
|
||||
# remove tags section at the front
|
||||
sed -i -e 's/tags:.*//g' "$NEWNAME"
|
||||
sed -i -e 's/---$//g' "$NEWNAME"
|
||||
|
||||
#remove markdown links
|
||||
sed -i -e 's/\[.*\](.*)//g' "$NEWNAME"
|
||||
|
||||
# remove html tags
|
||||
sed -i -e 's/<div id="page-break-after"\/>/\\pagebreak/g' "$NEWNAME"
|
||||
sed -i -e 's/<[a-zA-Z ]*>\(.*\)<\/[a-zA-Z =]*>/\1/g' "$NEWNAME"
|
||||
sed -i -e 's/<.*\/>//g' "$NEWNAME"
|
||||
|
||||
|
||||
echo "Generating LaTeX file..."
|
||||
echo "\documentclass[a4paper, 11pt]{article}
|
||||
|
||||
\usepackage[hybrid]{markdown}
|
||||
|
||||
\begin{document}
|
||||
\markdownInput{$1}
|
||||
\markdownInput{$NEWNAME}
|
||||
\end{document}" > file.tex
|
||||
|
||||
echo "Installing packages..."
|
||||
|
Loading…
Reference in New Issue
Block a user