In general, pretty-printing XHTML will change its meaning because
whitespace added or removed can affect the results. Instead of using
the xsl:strip-space functionality which is quite limited, use a normal
template to remove unwanted whitespace-only text nodes which can be
manually tweaked as required.
Then we explicitly add dummy nodes to prevent Nokogiri from reindenting
problematic cases, and finally clean those out just before publishing
(after all XSLT processing is finished).