feat: completed make_latex script
This commit is contained in:
parent
53d11c7bc3
commit
64f86314bf
@ -1,18 +1,43 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [ ! -f "$1" ]; then
|
if [ ! -f "$1" ]; then
|
||||||
echo "File $1 not found!"
|
echo "File $1 not found!"
|
||||||
echo "Usage: make_latex.sh <markdown-file>"
|
echo "Usage: make_latex.sh <markdown-file>"
|
||||||
exit
|
exit
|
||||||
fi
|
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 "Generating LaTeX file..."
|
||||||
echo "\documentclass[a4paper, 11pt]{article}
|
echo "\documentclass[a4paper, 11pt]{article}
|
||||||
|
|
||||||
\usepackage[hybrid]{markdown}
|
\usepackage[hybrid]{markdown}
|
||||||
|
|
||||||
\begin{document}
|
\begin{document}
|
||||||
\markdownInput{$1}
|
\markdownInput{$NEWNAME}
|
||||||
\end{document}" > file.tex
|
\end{document}" > file.tex
|
||||||
|
|
||||||
echo "Installing packages..."
|
echo "Installing packages..."
|
||||||
|
Loading…
Reference in New Issue
Block a user