In general, if derived formats including ePUB and MOBI from HTML,
also HTML from txt, also unwrapping txt from wrapped txt, are to work “correctly”
then there needs to be *some* degree of expectation on the formatting of
the incoming texts. Otherwise these tasks cannot be successfully automated.
Going the other way, the automated wrapping of txt is has
built-in support by most (all?) modern text tools, including web browsers,
e-book readers, text editors, etc.