Skip to content

Commit 5a88b8e

Browse files
committed
Add multiple possible environment templates
1 parent dec629c commit 5a88b8e

File tree

7 files changed

+30
-21
lines changed

7 files changed

+30
-21
lines changed

commands-tex.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ else
3434

3535
jq '.data.options[] | select(.name=="latex").value' "$1" -r >> $TEMPDIR/src.tex
3636

37-
bash latex-render.sh "$TEMPDIR"
37+
bash latex-render.sh "$TEMPDIR" "math"
3838

3939
if [ $? -eq 0 ]; then
4040
# Success!

latex-render.sh

+2-18
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,8 @@
11
TEMPDIR=$1
2+
TEXENV=$2
23
TEXFILE=$TEMPDIR/file.tex
34

4-
5-
cat <<END > $TEXFILE
6-
\documentclass[border=2pt]{standalone}
7-
\usepackage{amsmath}
8-
\usepackage{amsfonts}
9-
\usepackage{varwidth}
10-
\begin{document}
11-
\begin{varwidth}{\linewidth}
12-
\[
13-
END
14-
15-
cat $TEMPDIR/src.tex >> $TEXFILE
16-
17-
cat <<END >> $TEXFILE
18-
\]
19-
\end{varwidth}
20-
\end{document}
21-
END
5+
sed -e "/@CONTENT@/$TEMPDIR/src.tex" -e "d}" "tex-environments/$TEXENV.tex" > $TEXFILE
226

237
pdflatex --output-directory $TEMPDIR $TEXFILE >$TEMPDIR/tex.log 2>$TEMPDIR/tex-err.log && \
248
convert -density 300 -background white -alpha remove -quality 50 -colorspace RGB $TEMPDIR/file.pdf $TEMPDIR/file.png >$TEMPDIR/con.log 2>$TEMPDIR/con-err.log

modal-tex-render.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ echo
1111

1212
jq '.data.components[0].components[0].value' "$1" -r >> $TEMPDIR/src.tex
1313

14-
bash latex-render.sh "$TEMPDIR"
14+
bash latex-render.sh "$TEMPDIR" "math"
1515

1616
if [ $? -eq 0 ]; then
1717
# Success!

tex-environments/math.tex

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
\documentclass[border=2pt]{standalone}
2+
\usepackage{amsmath}
3+
\usepackage{amsfonts}
4+
\usepackage{varwidth}
5+
\begin{document}
6+
\begin{varwidth}{\linewidth}
7+
8+
\[
9+
@CONTENT@
10+
\]
11+
12+
\end{varwidth}
13+
\end{document}

tex-environments/none.tex

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
\documentclass[border=2pt]{standalone}
2+
\usepackage{amsmath}
3+
\usepackage{amsfonts}
4+
\usepackage{varwidth}
5+
\begin{document}
6+
\begin{varwidth}{\linewidth}
7+
8+
@CONTENT@
9+
10+
\end{varwidth}
11+
\end{document}

tex-environments/nopreamble.tex

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@CONTENT@

tex-eqtopng.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ TEXFILE=$TEMPDIR/file.tex
55

66
echo $QUERY_STRING | base64 -d >> $TEMPDIR/src.tex
77

8-
bash latex-render.sh "$TEMPDIR"
8+
bash latex-render.sh "$TEMPDIR" "math"
99

1010
echo "Content-Type: image/png"
1111
echo

0 commit comments

Comments
 (0)