Converting LaTeX Exams for Accessibility
Most of the time, I write most of my exams in plain text or markdown. I then use a Python script to convert the .txt file into (1) a study guide, (2) a practice CANVAS quiz, and (3) an exam using the LaTeX exam class. However, in some cases, the exam needs to be written in LaTeX since it makes use of custom packages for proofs or trees. The main problem with the latter approach is making the exams accessible.
Converting the exam with pandoc will not work since pandoc will not convert trees or proofs. My approach is as follows:
First, I created a build.py file. This file will serve to all the many scripts I need, e.g., running lualatex, converting the latex to html, moving files, etc.
Next, the first thing that the build.py file will do is run convert_latex_exam.py. This script will convert the exam class .tex file to a file formatted in a way that can be converted using lwarp. It works primarily by using regex commands to replace exam class commands with those found in the article class. For example:
content = re.sub(r'\\begin\{choices\}', r'\\begin{enumerate}', content)
Next, the build file runs lualatex on the converted file.