FIXED the prettyprint issues after some agony with JUICE: now using juice.inlineContent() and no more need for intermediate files either. Code adjusted to accept input from STDIN like this:

    node prettyprint.js < your_input_file

or

    cat input_file | node prettyprint.js
adjusted the prettyprint shell script accordingly.
Added the NBSP non-breaking-spaces thing too: now the output produces non-breaking spaces which should FORCE BookType to accept our indentation. (UNTESTED)