Hello Aditya,
Aditya Mahajan
If you are willing to add more markup, then TeX can do the parsing for you.
\startquestion[title={Ruby coloured by}, points=1, difficulty=1] A ruby is a gem of corundum colored \startoptions \option Rutile \option Calcium \correctoption Chrumium \option Iron and Titanium \stopoptions \starthint .... \stophint \startfeedback ... \stopfeedback \stopquestion
You can create a mode for ascii output that redefines all the environments to *typeset* the correct output, which you can then convert to text using pdftotext.
Another option is to write everything in XML (it is almost the same ...)
<text> A ruby .. </text> <options> <option> ... </option> <option> ... </option> <option correct="yes"> ... </option> <option> ... </option> </option> <hint> .... </hint> <feedback> ... </feedback> </question> With a few setup commands, ConTeXt can directly typeset an xml file. Parsing the xml file to generate ascii text can be done using your favourite programming language (or using ConTeXt by typesetting the desired output and using pdftotext).
Thank you very much. I will work on this over the next week and decide which method I like best. I really appreciate you taking the time to help. Best wishes, Roger