Hi Nicholas,
This is side-stepping your question, but I think it may be worth looking at for your underlying need. Over the past year or so I have added the "PTX" output mode (stands for PreTeXt). To the best degree I can make it happen, this processes the problem to output XML that works with PreTeXt (https://pretextbook.org/). From such XML, there would be ways to get simple static HTML or .tex versions of a question, including just using PreTeXt itself.
It's best to use a 2.14 server for this (or later) since I enhanced things recently.
Set the display mode to be "PTX" (instead of say "MathJax" or "images"). Maybe you need to do this directly in a course config file since I doubt "PTX" shows up in the Course Config GUI as an option. When you view the problem, your web browser will try to interpret the XML as HTML, so you can access the source to really see it.
Here is an example of what you can get. This is an OPL problem, rendered in the way you might embed a problem in some web page. Maybe you need to copy paste the whole link to get the "view source" part.
view-source:https://webwork.pcc.edu/webwork2/html2xml?&problemSeed=1&answersSubmitted=0&sourceFilePath=Library/PCC/BasicAlgebra/OrderOfOperations/orderOfOperations10.pg&displayMode=PTX&courseID=anonymous&userID=anonymous&course_password=open&outputformat=ptx
Note the URL has displaymode set to "PTX" and outputformat as "ptx".
There will be many problems in the OPL, particularly older ones, where PTX output will be malformed. Some coding techniques don't lend themselves to making PTX. Or at least I haven't figured out how to work them out yet.
Periodically I change the "password" details for having my server process files this way, so the link above may not work at some point.
Getting back to your question, you could scan through pg and webwork2 looking for instances of "PTX" and try making your own version of something like this, to output in a way that works for you. But maybe PTX output will be enough.