EPUB and HPUB implementation of #1054 logic.