docs: def latex2png(snippet, outfile):
      """Compiles a LaTeX snippet to png"""
      pngimage = os.path.join(IMAGEDIR, outfile + '.png')
      environment = os.environ
      environment['openout_any'] = 'a'
      environment['shell_escape_commands'] = \
          "bibtex,bibtex8,kpsewhich,makeindex,mpost,repstopdf,gregorio"
      proc = Popen(
          ["lualatex", '-output-directory=' + IMAGEDIR],
          stdin=PIPE,
          stdout=DEVNULL,
          env=environment
      )
      proc.stdin.write(
          (
              LATEX_DOC % (snippet)
          ).encode("utf-8")
      )
      proc.communicate()
      proc.stdin.close()
      call(["pdfcrop", os.path.join(IMAGEDIR, "texput.pdf")], stdout=DEVNULL)
      call(
          [
              "gs",
              "-sDEVICE=pngalpha",
              "-r144",
              "-sOutputFile=" + pngimage,
              os.path.join(IMAGEDIR, "texput-crop.pdf"),
          ],
          stdout=DEVNULL,
      )