I think the TOC is working now

It looks fine with my ePUBs, at least. Note that no attempt is done at fixing problematic files, and that it assumes linebreaks between elements in the .opf and .ncx files.
It also worked fine with a couple arbitrary Calibre-generated ePUBs I downloaded from MR, I'm happy