aboutsummaryrefslogtreecommitdiff
path: root/websvgtex
blob: df4e604176eace01ab7d868592e6d3350c9e3e0b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh

set -eux

rxrand="$(base64 < /dev/random | tr -d '/+=' | head -c 10)"

opwd="$(pwd)"

mkdir /tmp/websvgtex-$rxrand
cd /tmp/websvgtex-$rxrand

cat >m.tex <<EOF
\documentclass[preview]{standalone}
\usepackage{amsmath}
\begin{document}
EOF

cat /dev/stdin >>m.tex

cat >>m.tex <<EOF
\end{document}
EOF

{ set +u; } 2>/dev/null
if [ -z "$1" ]
then
	export_filename="m.svg"
else
	export_filename="$1"
fi
{ set -u; } 2>/dev/null

latex m.tex
latex m.tex
dvips m.dvi
inkscape m.ps --export-plain-svg --export-filename="$export_filename"

mv "$export_filename" "$opwd"