One of our main motivations for this project was mixing in code from the powerful, open source, mathematical software project, Sage (Section 3.17). When you add example Sage code to illustrate mathematical ideas, you are then encouraged to also include expected output in the <output> element. Here comes one of the powerful advantages of XML source and XSL processing.
The mathbook/xsl/pretext-sage-doctest.xsl stylesheet, used in the usual way, will create one, or several file(s), in exactly the format Sage expects for automated testing. So all your words are gone, and all your Sage input and output is packaged so Sage can run all the <input> and compare the results to the expected <output>. See Subsection 41.1.1 for details on obtaining more than one file.