nlbdev / nordic-epub3-dtbook-migrator

Tools for converting between a strict subset of DTBook and EPUB3.
http://nlbdev.github.io/nordic-epub3-dtbook-migrator/
GNU Lesser General Public License v2.1
8 stars 7 forks source link

Handle the case when you have chapters that only have an aria label and no heading. #539

Closed kalaspuffar closed 1 year ago

kalaspuffar commented 1 year ago

Hi @josteinaj

I think this is the issue vaguely referred to in https://github.com/nlbdev/nordic-epub3-dtbook-migrator/issues/522.

Currently, we will error and say that chapters are in the wrong level if we don't have a heading giving it a specific value for the level. When you have chapters that only have a section aria-label, we can't have any opinion on the specific placement in the hierarchy.

My fix might be a bit minimal, but if the XSLT doesn't create a @data-heading-depth, then we probably only have an aria-label section. Is that enough of a check, or do I need to see if we don't have an aria-label-by, then we need some work on the XSLT too?

Best regards Daniel

kalaspuffar commented 1 year ago

Hi @josteinaj

I have made the first part of the changes to this document. I wonder if we need to handle a depth larger than 6. I need to see an example to test this further. Maybe we should postpone that change until we have a document with significant depth.

Please review again.

Best regards Daniel

kalaspuffar commented 1 year ago

Hi @josteinaj

I slightly changed the xlst to get the section type of the document so we can check with the previous one. If the current document is a chapter with a previous part, we will add one to the section depth counter.

I hope this is a more robust solution. If I understand the specification, the epub:type attribute is mandatory, and the role attribute shall be used if a suitable role is available.

Please review it again.

Best regards Daniel

P.S. Forgot to mention I also removed the extra xslt documents and added them to ./createSchema.sh so we don't have to maintain these documents in two places. D.S.

josteinaj commented 1 year ago

I'll have to look more at this in January, I only have a couple of hours left until my Christmas vacation.

I need to check if we handle cases where a part does not have a visible headline (i.e. it uses aria-label), and where there's a chapter with a aria-label headline that follows a part, but is not in a part. In that corner case we might actually not be able to determine the depth based only on the content documents, but have to rely on the navigation document to determine if a section is in a part or not. We might also have to check for the bodymatter/backmatter boundary, we'll see.

kalaspuffar commented 1 year ago

Hi @josteinaj

Do we have any update on this PR?

Best regards Daniel

josteinaj commented 1 year ago

Hi @kalaspuffar.

Sorry, I haven't had time to look more into this.

I suspect we need more tests for this?

kalaspuffar commented 1 year ago

Hi @josteinaj

Well, I'll list the ones we have, and you decide if I should create another one.

  1. X50525A-12 is testing when we have parts and chapters in the same file with the correct heading levels.
  2. C0000-09 and 10 are testing chapters and parts in different files with the correct heading levels.
  3. C0000-13, 14, and 15 are testing when a chapter does not have a heading, only an aria-label
  4. C0000-16 and 17 are testing when the part has no heading, just an aria-label, and the chapter has the correct heading level.

Best regards Daniel

josteinaj commented 1 year ago

Ok, thank you. I'll look more at the tests later this week. But if I don't get time this week (which is likely), let's just merge it early next week and I'll assume it's fine.