-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathmakesvg
executable file
·19 lines (19 loc) · 959 Bytes
/
makesvg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash
grep "^SVGC" ffv1.md | cut -d : -f2- | while read svg_construct ; do
filename="$(echo "$svg_construct" | cut -d = -f1)"
if [[ ! -f "${filename}" ]] ; then
formula="$(echo "$svg_construct" | cut -d = -f2-)"
root="$(basename "$filename")"
echo "\pagenumbering{gobble}" > "${root}.md"
printf "$formula" >> "${root}.md"
pandoc -V fontsize=12pt -o "${root}.pdf" "${root}.md"
pdfcrop "${root}.pdf" "${root}_cropped.pdf"
pdf2svg "${root}_cropped.pdf" "${filename}.tmp"
cat "${filename}.tmp" | xmlstarlet edit -N "svg=http://www.w3.org/2000/svg" \
--delete "//svg:g/@style" \
--delete "//svg:path/@style" \
--rename "//svg:symbol" -v "g" \
--delete "//svg:g/@overflow" | sed "s|glyph|${filename}-glyph|g;s|surface|${filename}-surface|g" > "${filename}"
rm "${root}.md" "${root}.pdf" "${root}_cropped.pdf" "${filename}.tmp"
fi
done