Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Conversion

Notices

Reply
 
Thread Tools Search this Thread
Old 04-13-2020, 08:06 AM   #1
kapono
Junior Member
kapono began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Apr 2020
Device: Kobo Clara HD
Footnotes being detected as chapters

Hi everyone,

I'm converting an html page to epub that contains the title of the document inside an h1 on the html header and the chapter titles inside <h2> tags, but there is not attribute that contains the words ('chapter', 'section' etc.). So I changed the XPath expression that detects chapters into this
Code:
//*[((name()='h1' or name()='h2') and re:test(., '[a-z]+', 'i'))]
The regex is to avoid headers that are empty, there are a fer ones.

This rule worked well but It added the title of the book to the table of contents, resulting in a section without content. To avoid that I removed the 'h1' from the expression.
Code:
//*[(name()='h2' and re:test(., '[a-z]+', 'i'))]
But after that change, calibre is detecting all the footnotes that are at the end of the document in a <footer> as sections. I examined the html and there are no h1 nor h2 tags on the footer. Am I missing something?

The structure of the HTML is something like this:
Code:
<section>
  <h2 style="text-align: justify;"><a name="cap1"><strong>Lorem Ipsum</strong></a></h2>
  <p style="text-align: justify;">Mauris egestas vestibulum eros convallis sodales. Curabitur semper sapien quis tellus tempor ultrices. Donec sagittis pellentesque metus, in tempus velit. Suspendisse consectetur pretium erat vel consequat. </p>
  ....
  <footer>
    <font size="-1">
       <p style="text-align: justify;"><a href="#_ftnref1" name="_ftn1">[1]</a> Maecenas eu scelerisque justo, sed tristique dolor. </p>
       ...
    </font>
  </footer>
</section>
P.S.: I also tried withh this, but it keeps detecting the footnotes as sections in the Table of Contents
Code:
//h:section/h:h2
kapono is offline   Reply With Quote
Old 04-13-2020, 08:20 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
This is because your expression is not matching anything and calibre is fallign back to links. You need to use local-name() to match bare tag names without namespace for instance.
kovidgoyal is offline   Reply With Quote
Reply

Tags
footnotes, sections, table of contents, xpath


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Keep footnotes in the chapters during conversion. Chaim.Bar-Ilan Conversion 6 08-12-2023 11:25 AM
chapters opening as pop-up footnotes Fedwin Calibre 5 11-23-2014 12:25 AM
Footnotes added to TOC, and levels not detected eggheadbooks1 Conversion 2 05-10-2011 01:11 AM
azw to mobi: Not detecting chapters/page break at chapters and no TOC RachDvn Calibre 3 01-16-2011 09:53 AM
Getting Chapters detected Properly gandor62 Calibre 11 06-02-2010 09:31 PM


All times are GMT -4. The time now is 01:40 AM.


MobileRead.com is a privately owned, operated and funded community.