December Adventure Day 3

Published as part of 'December Adventure 2025' series.

Looking at yesterdays script's output, I noticed a bug. It's unexpected behavior, at least. Some entries of the table of contents were being duplicated. I didn't see any entries duplicated in the epub/toc.ncx file, which I assumed was the sole source the table of contents was being built from. But there's also epub/toc.xhtml, which I finally noticed. That has an extra section for "landmarks", like "bodymatter", "loi" (list of illustrations), and "endnotes". The "bodymatter" landmark points to text/book-1.xhmtl, one of the duplicated entries. Ah ha.

I didn't see a method for getting the table of contents without the landmarks, so as I build the list of pages in order, I'm skipping any entry with an item_type, which landmark items have and "regular" items don't.

That works for the epub file I'm starting with1. Who knows if it'll be a reliable way to handle this.

  1. Return of the Native by Thomas Hardy, from Standard Ebooks