Advertisement
andybuckley

pygtex

Sep 5th, 2017
643
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.00 KB | None | 0 0
  1. #! /usr/bin/env bash
  2.  
  3. ## Script to generate static .tex and .sty files equivalent to the minted TeX package output, but
  4. ## without requiring access to the shell-escape functionality banned on, for example, arXiv.
  5. ##
  6. ## Usage: pygtex source1.cpp source2.sh source3.py
  7. ## Then: \usepackage{pygtex} ... \input{source1-cpp} ... \input{source2-sh} ... \input{source3-py}
  8.  
  9. ## Write a .sty file defining the commands used in each Verbatim code block (bit hacky)
  10. echo "" | pygmentize -l python -f latex -P full=True | head -n -10 | grep -E -v "documentclass|inputenc" > pygtex.sty
  11.  
  12. ## Make a Verbatim code block for each input code file, transforming foo.ext to foo-ext.tex
  13. for inname in $@; do
  14.     outname=$(echo "$inname" | sed -e 's/[\ \.]/-/g').tex
  15.     # pygmentize -f latex -P verboptions='frame=leftline,framesep=1.5ex,framerule=0.8pt,gobble=2,fontsize=\smaller' $inname > $outname
  16.     pygmentize -f latex -P verboptions='frame=leftline,framesep=1.5ex,framerule=0.8pt,fontsize=\smaller' $inname > $outname
  17. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement