Comment 5 for bug 1393514

Revision history for this message
David Booth (david-booth12) wrote : Re: [Bug 1393514] Re: Incorrect nesting of sections in FB2 output

I have had a look at the code and have found there is a simple one-line fix. I have set up a Calibre development environment and have tested the fix. The updated file is attached. The line I have changed is line 438, within the function dump_text(). The original line was:                    if not (newlevel > self.section_level):
The changed line is:                    while not (newlevel > self.section_level):

The original code handled the case 'newlevel==self.section_level' correctly, but not the case 'newlevel<self.section_level', which requires more than one '</section>' to be inserted.
RegardsDavid Booth
      From: John Schember <email address hidden>
 To: <email address hidden>
 Sent: Saturday, 29 November 2014, 13:21
 Subject: [Bug 1393514] Re: Incorrect nesting of sections in FB2 output

The sectionize based on toc is a a best guess effort. It takes a number
various options that can impact the behavaior such as, "adjust the
"Structure Detection" and/or "Table of Contents" settings (turn on
"Force use of auto-generated Table of Contents"). It was never meant to
be a perfect conversion of toc to section.

FB2 being such a unique format and this feature being best used with
sectionize based on file (the reason this was created in the first
place), I'm not willing to work on this issue. If you'd like to look
into it further and attach a patch I'm willing to review it but
otherwise I'm closing this as won't fix.

** Changed in: calibre
      Status: In Progress => Won't Fix

--
You received this bug notification because you are subscribed to the bug
report.
https://bugs.launchpad.net/bugs/1393514

Title:
  Incorrect nesting of sections in FB2 output

Status in calibre: e-book management:
  Won't Fix

Bug description:
  I am developing an input plugin for Bibles in the OSIS format. The
  plugin creates a TOC with 3 levels - Testaments, Books and Chapters.
  This works fine for EPUB output. For FB2 output I am using "--
  sectionize toc" on the ebook-convert command line to try to create an
  equivalent table of contents. However, the actual table of contents I
  see when viewing the the FB2 output in either Calibre or  FBReader has
  all TOC entries except for the first Testamant and Book at level 3.
  i.e.:

  Old Testament
      Genesis
              Chapter 1
              ......
              Chapter  50
              Exodus                              (should be a level 2 entry, but is actually at level 3)
              Chapter 1
              ....

  This appears to be the result of incorrect nesting of sections in the
  FB2 output. At the end of a book there should be two </section> tags
  (to terminate chapter and book) and at the end of a testament there
  should be three </section> tags, but in each case there is only one
  such tag, other than at the very end of the document body.

  I am using Calibre 2.10 on Windows 7.

To manage notifications about this bug go to:
https://bugs.launchpad.net/calibre/+bug/1393514/+subscriptions