Skip to content

Instantly share code, notes, and snippets.

@anosatsuk124
Created November 9, 2023 11:14
Show Gist options
  • Save anosatsuk124/6011d3a9bfa20503858ce91a0621e133 to your computer and use it in GitHub Desktop.
Save anosatsuk124/6011d3a9bfa20503858ce91a0621e133 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
filename="$(basename "$1")"
temp="$(mktemp -d)/$filename"
pandoc -i "$1" -o "$temp".1.html
cat "$temp".1.html | perl -pe 's/<\/?ruby>//g' | perl -pe 's/<\/?rb>//g' | perl -pe 's/<rt>.*<\/rt>//g' | perl -pe 's/<svg.+$//g' > "$temp".2.html
pandoc "$temp".2.html --pdf-engine=lualatex -V documentclass=bxjsarticle -V classoption=pandoc -V pagestyle=empty -o "$filename".pdf
rm -rf "$temp.*"
echo "Done: $filename.pdf"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment